package com.software.first;import java.util.Scanner;public class Test {public static void main(String[] args) {Scanner scan = new Scanner(System.in);System.out.print("输入一个整数:");int x = scan.nextInt();System.out.print(x + "=");int y = 2; //最小的因数是2outer: while (x >= 1) { //当整数被除到数值为1时,就是被除尽的时候for (y = 2; y < x; y++) { //除数始终小于被除数if (x % y == 0) { //当余数为0时x = x / y; System.out.print(y + "*");continue outer; //第一轮循环结束后,重复执行以上过程}}break;}System.out.print(x); //最终无法整除的余数}
}
输入一个整数:12
12=2*2*3