public static IntStream primes(int max){
IntStream primes = IntStream.range(2, max);
IntFunction<IntPredicate> sieve = n->i->i==n || i % n != 0;
primes = primes.filter(sieve.apply(2));
for(int i = 3; i * i <= max; i++){
primes = primes.filter(sieve.apply(i));
}
return primes;
}
I am not able to understand How sieve and prime is calculated here ?The expression n->i->i==n || i % n != 0; I am not able to understand.