标签:imp int 结束 pos ati can actor int() 不能
题目:将一个正整数分解质因数。例如:输入90,打印出90=2x3 x3 x5。package who;
import java.util.Scanner;
/**
/
public class PrimeFactorDecompositon {
public static void main(String[] args) {
System.out.println("输入所求正整数:");
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int flag = 0;
// 质因数最小为2
int k = 2;
System.out.print(n + "=");
if (n < k) {
System.out.println("请输入正整数大于2");
}
while (n >= k) {
if (k == n) {
System.out.print(k);
break;
} else if (n % k == 0) {
System.out.print(k + "");
n = n / k;
} else {
k++;
}
}
}
}
标签:imp int 结束 pos ati can actor int() 不能
原文地址:https://blog.51cto.com/1929297/2459810