After getting through some of the SO posts, i found Sieve of Eratosthenes is the best & fastest way of generating prime numbers.
I want to generate the prime num
Sorenson Sieve might be worth a peek if space complexity is really an issue. Got the reference from the wikipedia page you shared.