素数 A prime is an integer greater than one whose only positive divisors are one and itself.
整数的素因子分解是乘积等于此素数的集合。
例如:3757208 = 2*2*2*7*13*13*397
public class Factors { public static void main(String[] args) { // Print the prime factors of N. long N = Long.parseLong(args[0]); long n = N; for (long i = 2; i <= n/i; i++) { // Cast out and print i factors while(n % i == 0) { n /= i; System.out.print(i + " "); // Any factors of n are greater than i. } } if (n > 1) System.out.print(n); System.out.println(); } }
没看懂...
[Introduction to programming in Java 笔记] 1.3.9 Factoring integers 素因子分解
原文:http://www.cnblogs.com/learning-c/p/5202402.html