P32 { public static List<Integer> primeFactors(int number) { List<Integer> fs = new ArrayList<>(); IntStream.rangeClosed(2, number / 2).filter(P31::isPrime).forEach(f -> { int n = number; while (n % f == 0) { n = n / f; fs.add(f); } }); return fs; }  static List<Integer> primeFactors(int number);  }
@Test public void shouldFindPrimeFactorsOf315() throws Exception { List<Integer> primeFactors = P32.primeFactors(315); assertThat(primeFactors, hasItems(3, 3, 5, 7)); }
@Test public void shouldFindPrimeFactorsOf33() throws Exception { List<Integer> primeFactors = P32.primeFactors(33); assertThat(primeFactors, hasItems(3, 11)); }