MathOverflow is a question and answer site for professional mathematicians. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I want an algorithm that outputs any $n$ distinct prime numbers, is there anything faster than Atkins' Sieve $O(n/log(log(n))$ ?

share|cite|improve this question
If you want to get $n$ prime numbers from the sieve, you have to generate all primes below about $n\log n$, so the sieve of Atkin per se takes time $O(n\log n/\log\log n)$. Having said that, if you want $n$ primes, most of them will have to have at least about $\log n$ digits, hence the sheer size of your output is already $\Omega(n\log n)$. In other words, the time needed to run the sieve is actually much smaller than the time it takes to print out the results (and this is true even in practice, if you look e.g. at DJ Bernstein’s implementation of the sieve). – Emil Jeřábek Sep 29 '11 at 13:33
Maybe I'm missing something, but how can the time needed to run the sieve be less than the time needed to print the results? You have to examine each of the $n$ primes at least once, and that will take $\log n$ time for each, so I don't see how the running time could be $O(n \log n/\log \log n)$. – Henry Cohn Sep 29 '11 at 16:40
The bound from the Atkin–Bernstein paper is for a RAM model with unit cost for arithmetical operations, I suppose. This corresponds well to real world, since your primes will not have more than 1 or 2 machine words. – Emil Jeřábek Sep 29 '11 at 17:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.