PrimeFactors { public List<Integer> getFactorsOf(int number) { List<Integer> factors = new ArrayList<Integer>(); int divisor = 2; while (number != 1) { while (number % divisor == 0) { number = number / divisor; factors.add(divisor); } divisor++; } return factors; }  List<Integer> getFactorsOf(int number);  }
@Test public void testThat2Returns2() { PrimeFactors factors = new PrimeFactors(); List<Integer> result = factors.getFactorsOf(2); assertThat(result).isEqualTo(Arrays.asList(2)); }
@Test public void testThat3Returns3() { PrimeFactors factors = new PrimeFactors(); List<Integer> result = factors.getFactorsOf(3); assertThat(result).isEqualTo(Arrays.asList(3)); }
@Test public void testThat4Returns2And2() { PrimeFactors factors = new PrimeFactors(); List<Integer> result = factors.getFactorsOf(4); assertThat(result).isEqualTo(Arrays.asList(2,2)); }
@Test public void testThat6Returns2And3() { PrimeFactors factors = new PrimeFactors(); List<Integer> result = factors.getFactorsOf(6); assertThat(result).isEqualTo(Arrays.asList(2, 3)); }
@Test public void testThat9Returns3And3() { PrimeFactors factors = new PrimeFactors(); List<Integer> result = factors.getFactorsOf(9); assertThat(result).isEqualTo(Arrays.asList(3, 3)); }
@Test public void testThat12Returns2And2And3() { PrimeFactors factors = new PrimeFactors(); List<Integer> result = factors.getFactorsOf(12); assertThat(result).isEqualTo(Arrays.asList(2, 2, 3)); }
@Test public void testThat15Returns3And5() { PrimeFactors factors = new PrimeFactors(); List<Integer> result = factors.getFactorsOf(15); assertThat(result).isEqualTo(Arrays.asList(3, 5)); }