C语言 对正整数进行分解质因数
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main(void)
{
int num
;
int i
;
printf("输入一个正整数:\n");
scanf("%d", &num
);
for(i
= 2; i
<= sqrt(num
); i
++)
{
if(num
% i
== 0 && num
/ i
!= 1)
{
printf("%d * ",i
);
num
= num
/i
;
i
= 1;
}
}
printf("%d", num
);
system("pause");
return 0;
}
转载请注明原文地址:https://tech.qufami.com/read-18487.html