将一个正整数分解质因数。
import java.util.Scanner;
/**
* 题目: 将一个正整数分解质因数。 例如:输入90,打印出90 = 2*3*3*5.
*/
public class FenJie {
public static void main(String[] args) {
int parm = 0;
System.out.println("请输入数字:");
Scanner scanner = new Scanner(System.in);
parm = scanner.nextInt();
System.out.print(parm + "=");
for (int i = 2; i <= parm; i++) {
while (parm != i) {
if (parm % i == 0) {
System.out.print(i + "*");
parm = parm / i;
} else {
break;
}
}
}
System.out.print(parm);
}
}