我正在尝试创建一个程序,根据吸血鬼号码是否是我迄今为止所做的代码返回true或false:
typedef unsigned int uint;
uint fact(uint a, uint r)
{
static uint primes[10] = {2, 3, 5, 7, 11, 13, 17, 23, 29, 31};
if (a){ r *= primes[a % 10]; fact(a / 10, r); }
else return r;
}
uint permute(uint number)
{
// I don't know how to go permuting the numbers
return check(a, b) ;
}
uint check(uint a, uint b)
{
uint v = a * b;
if (fact(a,1) * fact(b, 1) == fact(v, 1))
return 1;
else
return 0;
}
int main(void)
{
int number = 1260; //number vampire
return 0;
}
缺点是我不知道如何产生f牙¿任何人都可以帮助我吗?一切都应该使用递归而不是循环