题解 | #质数因子#
质数因子
https://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607
#include <stdio.h>
#include <math.h>
int main() {
int input; //输入的正整数
scanf("%d", &input);
int tmp1 = 2, tmp2 = input;
if (tmp2 == 1) {
printf("%d", tmp2);
}
while (tmp2 != 1) {
if (tmp1 > sqrt(tmp2)) {
printf("%d", tmp2);
printf(" ");
break;
} else {
if ( tmp2 % tmp1 == 0) {
printf("%d", tmp1);
printf(" ");
tmp2 = tmp2 / tmp1;
// if (tmp2 == 1) {
// break;
// }
} else {
tmp1++;
}
}
}
return 0;
}

哔哩哔哩公司氛围 723人发布