Sieving Primes 2
Success! I found a reference to Mertens’ theorem in a paper by Adam Kalai, which is exactly what I needed to analyze the complexity of the prime sieve from the previous post.
Alas, my previous complexity guess was wrong. The actual complexity is . Apparently my numerical estimates didn’t go out far enough (also I was biased towards finding ).
From before, the cost of the algorithm is where where means all composite numbers up to . Note that any number with can be written as , where is not divisible by any prime smaller than . By Mertens’ theorem, the density of numbers not divisible by primes less than is We can now estimate as Since the integrand is for , we get . On the other hand, the integrand is for , so in fact .
This adds another entry to the set of listful Sieve of Eratostheness-like algorithms that turn out to cost as much as trial division (up to a polylog factor). It’d be cool if a faster list based algorithm existed, but I expect that the answer is probably no.