Which is the fastest algorithm to find prime numbers?

kasperasky picture kasperasky · Jan 17, 2009 · Viewed 324.3k times · Source

Which is the fastest algorithm to find out prime numbers using C++? I have used sieve's algorithm but I still want it to be faster!

Answer

Greg Hewgill picture Greg Hewgill · Jan 17, 2009

A very fast implementation of the Sieve of Atkin is Dan Bernstein's primegen. This sieve is more efficient than the Sieve of Eratosthenes. His page has some benchmark information.