Use optimized Sieve of Eratosthenes for prime generation.