public class PrimeFactorization {
public static void primeFactorization(int num){
if(num < 2){
throw new IllegalArgumentException("入参请用大于等于2的整数!");
}
int max = num;
for(int i=2; i<=max; i++){
if(num % i == 0){
num = num / i;
System.out.print(i + " ");
if(num % i == 0){
i --;
}
}
if(num < i){
break;
}
}
}
public static void main(String[] args) {
primeFactorization(1234567890);
}
}
程序输出结果:2 3 3 5 3607 3803