标签:[] next scanner can 质因数 logs java编程 java system.in
package Solve; import java.util.Scanner; public class Solve { static Scanner scan = new Scanner(System.in); public static void main(String[] args) { System.out.println("请输入一个正整数:"); int num = scan.nextInt(); System.out.print(num + " = "); int k = 2; while ( k <= num ) { if ( k == num ) { System.out.println(num); break; } else if ( num % k == 0) { System.out.print( k + "*"); num /= k; } else k++; } } } //题目: 将一个正整数分解质因数 . 例如: 90 = 2 * 3 * 3 * 5
标签:[] next scanner can 质因数 logs java编程 java system.in
原文地址:http://www.cnblogs.com/lfm1996/p/6361720.html