1. 质因数分解
public static List<Integer> factorize(int n){ List<Integer> factors = new ArrayList(); int i; boolean isPrime = true; for (i = 2; i <= Math.sqrt(n); i++){ if (n % i == 0){ factors.add(i); isPrime = false; break; } } if (isPrime){ factors.add(n); }else{ factors.addAll(factorize( n / i)); } return factors; }