System.out.print("请输入一个正整数: ");
Scanner s=new Scanner(System.in);
int n=s.nextInt();
System.out.print("分解质因数:"+n+"=");
for (int j = 2; j <= n; j++) {
while (n>j) {
if (n%j==0) {
n=n/j;
System.out.print(j);
System.out.print("*");
}
else {
break;
}
}
while (n==j) {
System.out.print(j);
break;
}
} |