题解 | #质数因子#
质数因子
https://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607
#include <stdio.h>
#include <math.h>
int main()
{
long int n = 0, i = 0;
scanf("%ld", &n);
for(i=2; i<=sqrt(n); i++)
{
while(n%i == 0)//没有机会判断i=4,因为i=2就会打印一次
{ printf("%ld ", i);
n/=i;
}
}
if(i < n)
printf("%ld ", n);
return 0;
}

叮咚买菜工作强度 246人发布