Optimized sieve of Erathostenes