### Question:
Primes { public static IntStream primes(int max) { return IntStream .range(2, max + 1) .filter(candidate -> isPrimeStream(candidate)); }  static IntStream primes(int max); static IntStream primes(int max, BiFunction<List<Integer>, Integer, Boolean> isPrime); static boolean isPrimeOpt2(List<Integer> primes, int candidate); static boolean isPrimeOpt(List<Integer> primes, int candidate); static boolean isPrimeStream(int candidate); static boolean isPrimeImperative(int candidate);  }### Answer:
@Test public void testPrimes() { for (int i = 0; i < 5; i++) { System.out.println("############################"); System.out.println(measurePerformance(() -> Primes.primes(10000, Primes::isPrimeOpt).count())); System.out.println(measurePerformance(() -> Primes.primes(10000, Primes::isPrimeOpt2).count())); } }