P34 { public static List<Integer> primeNumbers(IntStream range) { return range.filter(P31::isPrime).boxed().collect(Collectors.toList()); }  static List<Integer> primeNumbers(IntStream range); static List<Integer> primeNumbers_sieve(final int start, final int end);  }
@Test public void shouldGiveAllPrimeNumbersBetween2And10() throws Exception { List<Integer> primeNumbers = P34.primeNumbers(IntStream.rangeClosed(2, 10)); assertThat(primeNumbers, hasSize(4)); assertThat(primeNumbers, hasItems(2, 3, 5, 7)); }
@Test public void shouldGiveAllPrimeNumbersBetween7And31() throws Exception { List<Integer> primeNumbers = P34.primeNumbers(IntStream.rangeClosed(7, 31)); assertThat(primeNumbers, hasSize(8)); assertThat(primeNumbers, hasItems(7, 11, 13, 17, 19, 23, 29, 31)); }