Advertisement

On the Complexity of Computing Prime Tables

  • Martín Farach-Colton
  • Meng-Tsung Tsai
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 9472)

Abstract

Many large arithmetic computations rely on tables of all primes less than n. For example, the fastest algorithms for computing n! takes time \(\mathcal {O}(\mathrm {M}(n\log n) + \mathrm {P}(n))\), where \(\mathrm {M}(n)\) is the time to multiply two n-bit numbers, and \(\mathrm {P}(n)\) is the time to compute a prime table up to n. The fastest algorithm to compute \(\left( {\begin{array}{c}n\\ n/2\end{array}}\right) \) also uses a prime table. We show that it takes time \(\mathcal {O}(\mathrm {M}(n) + \mathrm {P}(n))\).

In various models, the best bound on \(\mathrm {P}(n)\) is greater than \(\mathrm {M}(n\log n)\), given advances in the complexity of multiplication [8, 13]. 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 \(\mathcal {O}(\mathrm {M}(n\log n))\) and \(\mathcal {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 \(\mathrm {M}(n)\) is \(n\log n 2^{\mathcal {O}(\log ^*n)}\), the second algorithm is faster and improves on the previous best algorithm by a factor of \(\log ^2\log n\). Our fast prime-table algorithms speed up both the computation of n! and \(\left( {\begin{array}{c}n\\ n/2\end{array}}\right) \).

Finally, we show that computing the factorial takes \(\Omega (\mathrm {M}(n \log ^{4/7 - \varepsilon } n))\) for any constant \(\varepsilon > 0\) assuming only multiplication is allowed.

Keywords

Prime tables Factorial Multiplication Lower bound 

References

  1. 1.
    Agrawal, M., Kayal, N., Saxena, N.: Primes is in P. Ann. of Math. 2, 781–793 (2002)MathSciNetzbMATHGoogle Scholar
  2. 2.
    Atkin, A.O.L., Bernstein, D.J.: Prime sieves using binary quadratic forms. Math. Comput. 73(246), 1023–1030 (2004)MathSciNetCrossRefzbMATHGoogle Scholar
  3. 3.
    Behrend, F.A.: On sets of integers which contain no three terms in arithmetical progression. Proc. Natl. Acad. Sci. USA 32(12), 331–332 (1946)MathSciNetCrossRefzbMATHGoogle Scholar
  4. 4.
    Berkovich, S., Lapir, G.M., Mack, M.: A bit-counting algorithm using the frequency division principle. Softw. Pract. Exper. 30(14), 1531–1540 (2000)CrossRefzbMATHGoogle Scholar
  5. 5.
    Boiten, E.A.: Factorisation of the factorial-an example of inverting the flow of computation. Periodica Polytechnica SER. EL. ENG. 35(2), 77–99 (1991)Google Scholar
  6. 6.
    Borwein, P.B.: On the complexity of calculating factorials. J. Algorithms 6(3), 376–380 (1985)MathSciNetCrossRefzbMATHGoogle Scholar
  7. 7.
    Bourgain, J.: Roth’s theorems in progressions revisited. Tech. rep. (2007)Google Scholar
  8. 8.
    De, A., Kurur, P.P., Saha, C., Saptharishi, R.: Fast integer multiplication using modular arithmetic. In: 40th Annual ACM Symposium on Theory of Computing (STOC), pp. 499–506 (2008)Google Scholar
  9. 9.
    Dickson, L.E.: History of the Theory of Numbers: Divisibility and Primality. Dover Publications, New York (2005)zbMATHGoogle Scholar
  10. 10.
    Elkin, M.: An improved construction of progression-free sets. In: 21st Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pp. 886–905 (2010)Google Scholar
  11. 11.
    Erdös, P., Turán, P.: On some sequences of integers. J. Lond. Math. Soc. 11, 261–264 (1936)MathSciNetCrossRefzbMATHGoogle Scholar
  12. 12.
    Farach-Colton, M., Tsai, M.: On the complexity of computing prime tables. CoRR abs/1504.05240 (2015)Google Scholar
  13. 13.
    Fürer, M.: Faster integer multiplication. In: 39th Annual ACM Symposium on Theory of Computing (STOC), pp. 57–66 (2007)Google Scholar
  14. 14.
    Fürer, M.: How fast can we multiply large integers on an actual computer? In: Pardo, A., Viola, A. (eds.) LATIN 2014. LNCS, vol. 8392, pp. 660–670. Springer, Heidelberg (2014) CrossRefGoogle Scholar
  15. 15.
    Grosswald, E.: Representations of Integers as Sums of Squares. Springer, New York (1985) CrossRefzbMATHGoogle Scholar
  16. 16.
    Guy, R.: Unsolved Problems in Number Theory. Springer, New York (2004) CrossRefzbMATHGoogle Scholar
  17. 17.
    Uspensky, J.V., Heaslet, M.A.: Elementary Number Theory. McGraw-Hill, New York (1939) zbMATHGoogle Scholar
  18. 18.
    Knuth, D.E.: The Art of Computer Programming: Seminumerical Algorithms. Addison-Wesley, Reading (1997) zbMATHGoogle Scholar
  19. 19.
    Kummer, E.: Über die ergänzungssätze zu den allgemeinen reciprocitätsgesetzen. Journal für die reine und angewandte Mathematik 44, 93–146 (1852)MathSciNetCrossRefGoogle Scholar
  20. 20.
    LeVeque, W.J.: Topics in Number Theory. Dover, New York (2002) zbMATHGoogle Scholar
  21. 21.
    Moser, L.: On non-averaging sets of integers. Can. J. Math. 5, 245–253 (1953)MathSciNetCrossRefzbMATHGoogle Scholar
  22. 22.
    Roth, K.F.: On certain sets of integers. J. Lond. Math. Soc. s1–28(1), 104–109 (1953)MathSciNetCrossRefzbMATHGoogle Scholar
  23. 23.
    Salem, R., Spencer, D.C.: On sets of integers which contain no three terms in arithmetical progression. Proc. Natl. Acad. Sci. USA 28(12), 561–563 (1942)MathSciNetCrossRefzbMATHGoogle Scholar
  24. 24.
    Schönhage, A., Grotefeld, A., Vetter, E.: Fast algorithms: A Multitape Turing Machine Implementation. Wissenschaftsverlag, B.I, Mannheim (1994) zbMATHGoogle Scholar
  25. 25.
    Schönhage, A., Strassen, V.: Schnelle multiplikation grosser zahlen. Computing 7, 281–292 (1971)MathSciNetCrossRefzbMATHGoogle Scholar
  26. 26.
    Ugur, A., Thompson, H.: The p-sized partitioning algorithm for fast computation of factorials of numbers. J. Supercomput. 38(1), 73–82 (2006)CrossRefGoogle Scholar
  27. 27.
    Vardi, I.: Computational Recreations in Mathematica. Addison-Wesley, New York (1991) zbMATHGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2015

Authors and Affiliations

  1. 1.Rutgers UniversityNew BrunswickUSA

Personalised recommendations