题解 | #质数因子#
质数因子
https://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607
#include<stdio.h> int main(){ int numb = 0; scanf("%d", &numb); int i = 0; //合数的最小质因数必小于等于该数的平方根 for(i=2; i*i<=numb; i++){ //同因数连除 while(numb%i == 0){ printf("%d ", i); numb /= i; } } //未被除到1,是质数 if(numb>1){ printf("%d", numb); numb /= numb; } return 0; }