用c语言写这个程序 分解质因子:将一个正整数m(m>=2)表示成它的质因子乘积的方式
时间: 2023-06-06 22:05:18 浏览: 82
实现质因数分解的程序,输出这个数的质因数的连乘形式分解质因数.zip
Sure, I can help you with that! Here's the C program to factorize a given integer:
```c
#include <stdio.h>
int main() {
int n, i;
printf("Enter a positive integer greater than or equal to 2: ");
scanf("%d", &n);
printf("Prime factorization of %d: ", n);
for (i = 2; i <= n; i++) {
while (n % i == 0) {
printf("%d ", i);
n /= i;
}
}
printf("\n");
return 0;
}
```
You can compile and run this program in any C environment, such as GCC or Visual Studio. The program takes a positive integer greater than or equal to 2 as input from the user, and then it finds all the prime factors of that integer and prints them on the screen. I hope this helps!
阅读全文