@Test public void testNonPositive() { assertEquals(0, PrimeFactors.generate(-1).size()); assertEquals(0, PrimeFactors.generate(0).size()); }
public static List<Integer> generate(int n) { if (n <= 1) { return Collections.emptyList(); } List<Integer> resultList = new ArrayList<>(); for (int index = 2; index <= n; index++) { if (isFactor(index, n) && isPrime(index)) { resultList.add(index); } } return resultList; }
PrimeFactors { public static List<Integer> generate(int n) { if (n <= 1) { return Collections.emptyList(); } List<Integer> resultList = new ArrayList<>(); for (int index = 2; index <= n; index++) { if (isFactor(index, n) && isPrime(index)) { resultList.add(index); } } return resultList; } }
PrimeFactors { public static List<Integer> generate(int n) { if (n <= 1) { return Collections.emptyList(); } List<Integer> resultList = new ArrayList<>(); for (int index = 2; index <= n; index++) { if (isFactor(index, n) && isPrime(index)) { resultList.add(index); } } return resultList; }  }
PrimeFactors { public static List<Integer> generate(int n) { if (n <= 1) { return Collections.emptyList(); } List<Integer> resultList = new ArrayList<>(); for (int index = 2; index <= n; index++) { if (isFactor(index, n) && isPrime(index)) { resultList.add(index); } } return resultList; }  static List<Integer> generate(int n); }
PrimeFactors { public static List<Integer> generate(int n) { if (n <= 1) { return Collections.emptyList(); } List<Integer> resultList = new ArrayList<>(); for (int index = 2; index <= n; index++) { if (isFactor(index, n) && isPrime(index)) { resultList.add(index); } } return resultList; }  static List<Integer> generate(int n);  }