题解 | #质数因子#
质数因子
http://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607
#include "stdio.h"
int main()
{
long int n;
long int a = 5, b = 7, c = 11;
scanf("%ld", &n);
for (int i=2; i<=n; )
{
while (n%i == 0)
{
printf("%d ", i);
n /= i;
}
if(i < 11)
{
i++;
}
else
{
i = b + c - a;
a = b;
b = c;
c = i;
}
}
}
分析中发现质数为 2 3 5 7 11 13 17 19 其中 13 = 11 + 7 -5; 17 = 13 + 11 - 7; 19 = 13 + 17 - 11; 得出 i = b + c - a; a = b; b = c; c = i;