Demo04分解质因数

package 习题集1;

import java.util.Scanner;

//将一个正整数分解质因数。例如输入90,打印出90=2*3*3*5
public class Demo04 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int count = sc.nextInt();
System.out.print(count + "=");
for (int i = 2;i < count / 2 + 1;i ++) {
if (count % i == 0) {
System.out.print(i + "*");
count = count / i;
i = 1;
}
}
System.out.println(count);
}
}
posted @ 2020-07-14 10:11  筆尖下的沉默  阅读(76)  评论(0编辑  收藏  举报