题目描述:
将一个正整数N(1< N< 32768)分解质因数。例如,输入90,打印出90=2*3*3*5。
代码:
package lanqiao;import java.util.*;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();int b = 1;System.out.print(n + "=");while(n != 1){b ++;if(n % b == 0){n = n/b;if(n == 1){System.out.print(b);}else{System.out.print(b + "*");b = 1;}}}}
}