P35 { public static List<Integer> goldbach(int number) { if (number == 2) { return Collections.emptyList(); } else if (number % 2 != 0) { return Collections.emptyList(); } List<Integer> primeNumbers = P34.primeNumbers(IntStream.rangeClosed(2, number)); for (Integer primeNumber : primeNumbers) { if (primeNumbers.contains(number - primeNumber)) { return Arrays.asList(primeNumber, number - primeNumber); } } throw new RuntimeException("Should not have happened!!"); }  static List<Integer> goldbach(int number);  }
@Test public void _8_isthesumof_3_and_5() throws Exception { List<Integer> numbers = P35.goldbach(8); assertThat(numbers, hasSize(2)); assertThat(numbers, hasItems(3, 5)); }
@Test public void _4_isthesumof_2_and_2() throws Exception { List<Integer> numbers = P35.goldbach(4); assertThat(numbers, hasSize(2)); assertThat(numbers, hasItems(2, 2)); }
@Test public void _28_isthesumof_5_and_23() throws Exception { List<Integer> numbers = P35.goldbach(28); assertThat(numbers, hasSize(2)); assertThat(numbers, hasItems(5, 23)); }