Papers › Computing π(N): An elementary approach in Õ(√(N)) time
Computing π(N): An elementary approach in Õ(√(N)) time
Dean Hirsch, Ido Kessler, Uri Mendlovic
The archive published only this paper's code-link row. Authors, date and abstract are from arXiv's metadata (CC0), read from the Kaggle arXiv metadata snapshot of 2026-09-12 where its title matched the archive's; the title is the archive's.
We present an efficient and elementary algorithm for computing the number of primes up to N in Õ(√(N)) time, improving upon the existing combinatorial methods that require Õ(N ^(2/3)) time. Our method has a similar time complexity to the analytical approach to prime counting, while avoiding complex analysis and the use of arbitrary precision complex numbers. While the most time-efficient version of our algorithm requires Õ(√(N)) space, we present a continuous space-time trade-off, showing, e.g., how to reduce the space complexity to Õ(√(N)) while slightly increasing the time complexity to Õ(N^(8/15)). We apply our techniques to improve the state-of-the-art complexity of elementary algorithms for computing other number-theoretic functions, such as the the Mertens function (in Õ(√(N)) time compared to the known Õ(N^(0.6))), summing Euler's totient function, counting square-free numbers and summing primes. Implementation code is provided.
Code
Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.
Code Syntology ran Syntology
Not run by Syntology. Nothing on this page verifies that the listed code works.
Results from the paper archive 2025-07-28
No leaderboard rows for this paper in the archive.
Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections