题解 | #质数因子#
质数因子
http://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607
C代码示例:
#include <stdio.h> #include <math.h> void yinzi(long num) { int flag = 0; for(int i=2; i<=sqrt(num);i++){ if(num%i == 0){ printf("%d ", i); flag = 1; yinzi(num/i); break; } } if(flag == 0) printf("%d ", num); } int main(){ long num; scanf("%ld", &num); yinzi(num); return 0; }