Exact prime counting and deterministic prime finding in time No(1)N^{o(1)}

A mix of human-written and AI-generated textHuman understanding: some partscs.CC — Computational Complexitymath.NT — Number Theory

Contributed by Jiayan Ni ↗

Version 1 / Dec 01, 2026 / CC BY 4.0

Abstract

We prove that the exact sum S(N)=∑p≤NpS(N)=\sum_{p\le N}p of the primes up to NN, the exact prime count π(N)\pi(N) and, for N≥1N\ge1, a prime in (N,2N](N,2N] can each be computed by a deterministic Turing machine in 2O(b/log⁡b)=No(1)2^{O(b/\sqrt{\log b})}=N^{o(1)} steps, where bb is the bit length of NN. For all three problems the best bounds known so far were N1/2+o(1)N^{1/2+o(1)}; for π(N)\pi(N) this exponent has stood since the analytic method of Lagarias and Odlyzko in 1987. In particular, whether a given interval in [N,2N][N,2N] contains a prime can be decided in time No(1)N^{o(1)}. This establishes, in a much stronger form, a conjecture of the Polymath4 project, which asked for time N1/2−cN^{1/2-c} for some c>0c>0 and for intervals of length at most N1/2+cN^{1/2+c}. The theorems are obtained by reducing the three problems to the subexponential counting algorithm behind the recent refutation of the Exponential Time Hypothesis; they are asymptotic statements, not practical algorithms. The reduction rests on an analytic idea: Ramanujan sums express the M\"obius function without factoring, and a Cauchy-kernel quadrature turns the phases, the logarithm and its reciprocal into short linear combinations of rational functions, which a counting network of linear size can evaluate. All three theorems, together with the counting algorithm they rely on, are formally verified in Lean~4 against a specification that imports only Mathlib.

Provenance statement

The parts have been checked by the author but not by more professional peers in theoretical CS/number theory.

Tools used

OpenAI
CodexVersion 6 Astra
Anthropic
Claude FableVersion 5.2

References

  1. Anthropic, A 2o(n)2^{o(n)} time algorithm for 3-SAT , Hexagon 2610.00577 (2026); Lean formalization at https://github.com/anthropics/formal-math.link
  2. M. Agrawal, N. Kayal and N. Saxena, PRIMES is in P , Ann. of Math. (2) 160 (2004), 781--793.
  3. R. C. Baker, G. Harman and J. Pintz, The difference between consecutive primes, II , Proc. London Math. Soc. (3) 83 (2001), 532--562.
  4. L. Chen, Z. Lu, I. C. Oliveira, H. Ren and R. Santhanam, Polynomial-time pseudodeterministic construction of primes , Proc.\ 64th IEEE Symposium on Foundations of Computer Science (FOCS 2023); arXiv:2305.15140.arXiv
  5. H. Cramér, On the order of magnitude of the difference between consecutive prime numbers , Acta Arith. 2 (1936), 23--46.
  6. M. Deléglise and J. Rivat, Computing π(x)\pi(x): the Meissel, Lehmer, Lagarias, Miller, Odlyzko method , Math. Comp. 65 (1996), 235--245.
  7. D. Hirsch, I. Kessler and U. Mendlovic, Computing π(N)\pi(N): an elementary approach in O~(N)\tilde O(\sqrt N) time , Math. Comp. 94 (2025), no. 356, 3043--3081; arXiv:2212.09857.arXiv
  8. H. A. Helfgott and L. Thompson, Summing μ(n)\mu(n): a faster elementary algorithm , Res. Number Theory 9 (2023), Paper No. 6.
  9. R. Impagliazzo and R. Paturi, On the complexity of kk-SAT , J. Comput. System Sci. 62 (2001), 367--375.
  10. D. H. Lehmer, On the exact number of primes less than a given limit , Illinois J. Math. 3 (1959), 381--388.
Show all 22 referencesShow fewer references
  1. J. C. Lagarias, V. S. Miller and A. M. Odlyzko, Computing π(x)\pi(x): the Meissel--Lehmer method , Math. Comp. 44 (1985), 537--560.
  2. J. C. Lagarias and A. M. Odlyzko, Computing π(x)\pi(x): an analytic method , J. Algorithms 8 (1987), 173--191.
  3. OpenAI, The Exponential Time Hypothesis is false , preprint (October 2026), https://github.com/openai/math.link
  4. I. C. Oliveira and R. Santhanam, Pseudodeterministic constructions in subexponential time , Proc.\ 49th ACM Symposium on Theory of Computing (STOC 2017), 665--677.
  5. T. Tao, (Research thread II) Deterministic way to find primes , The polymath blog, August 9, 2009, https://polymathprojects.org/2009/08/09/research-thread-ii-deterministic-way-to-find-primes/.link
  6. D. J. Platt, Computing π(x)\pi(x) analytically , Math. Comp. 84 (2015), 1521--1535.
  7. S. Ramanujan, On certain trigonometrical sums and their applications in the theory of numbers , Trans. Cambridge Philos. Soc. 22 (1918), 259--276.
  8. I. Rudich and L.-M. Rousseau, Deterministic factoring in time No(1)N^{o(1)} , Hexagon 2610.00600 (2026).
  9. T. Tao, E. Croot III and H. Helfgott, Deterministic methods to find primes , Math. Comp. 81 (2012), 1233--1246; arXiv:1009.3956, as D. H. J. Polymath.arXiv
  10. L. N. Trefethen and J. A. C. Weideman, The exponentially convergent trapezoidal rule , SIAM Rev. 56 (2014), 385--458.
  11. V. Tulsyan, The parity of the prime-counting function in time xo(1)x^{o(1)} , Hexagon 2611.00116 (2026); Lean library at https://github.com/xennygrimmato/eth-hamiltonicity.link
  12. V. Tulsyan, What the ETH refutations do not give: barriers for the counting engines, with machine-checked lemmas , Hexagon 2611.00149 (2026).

Version history

  1. v1 · 37 pagesSubmitted by Jiayan NiInitial depositCurrentDec 01, 2026