English

On the complexity of computing prime tables

Computational Complexity 2015-04-22 v1 Data Structures and Algorithms

Abstract

Many large arithmetic computations rely on tables of all primes less than nn. For example, the fastest algorithms for computing n!n! takes time O(M(nlogn)+P(n))O(M(n\log n) + P(n)), where M(n)M(n) is the time to multiply two nn-bit numbers, and P(n)P(n) is the time to compute a prime table up to nn. The fastest algorithm to compute (nn/2)\binom{n}{n/2} also uses a prime table. We show that it takes time O(M(n)+P(n))O(M(n) + P(n)). In various models, the best bound on P(n)P(n) is greater than M(nlogn)M(n\log n), given advances in the complexity of multiplication \cite{Furer07,De08}. In this paper, we give two algorithms to computing prime tables and analyze their complexity on a multitape Turing machine, one of the standard models for analyzing such algorithms. These two algorithms run in time O(M(nlogn))O(M(n\log n)) and O(nlog2n/loglogn)O(n\log^2 n/\log \log n), respectively. We achieve our results by speeding up Atkin's sieve. Given that the current best bound on M(n)M(n) is nlogn2O(logn)n\log n 2^{O(\log^*n)}, the second algorithm is faster and improves on the previous best algorithm by a factor of log2logn\log^2\log n. Our fast prime-table algorithms speed up both the computation of n!n! and (nn/2)\binom{n}{n/2}. Finally, we show that computing the factorial takes Ω(M(nlog4/7ϵn))\Omega(M(n \log^{4/7 - \epsilon} n)) for any constant ϵ>0\epsilon > 0 assuming only multiplication is allowed.

Keywords

Cite

@article{arxiv.1504.05240,
  title  = {On the complexity of computing prime tables},
  author = {Martin Farach-Colton and Meng-Tsung Tsai},
  journal= {arXiv preprint arXiv:1504.05240},
  year   = {2015}
}
R2 v1 2026-06-22T09:19:23.417Z