Optimize prime generation with sieve
Optimize prime generation (Lucas test)