, Volume 9, Issue 4, pp 313–328

Sieve algorithms for perfect power testing

  • Eric Bach
  • Jonathan Sorenson


A positive integern is a perfect power if there exist integersx andk, both at least 2, such thatn=xk. The usual algorithm to recognize perfect powers computes approximatekth roots fork≤log2n, and runs in time O(log3n log log logn).

First we improve this worst-case running time toO(log3n) by using a modified Newton's method to compute approximatekth roots. Parallelizing this gives anNC2 algorithm.

Second, we present a sieve algorithm that avoidskth-root computations by seeing if the inputn is a perfectkth power modulo small primes. Ifn is chosen uniformly from a large enough interval, the average running time isO(log2n).

Third, we incorporate trial division to give a sieve algorithm with an average running time ofO(log2 n/log2 logn) and a median running time ofO(logn).

The two sieve algorithms use a precomputed table of small primes. We give a heuristic argument and computational evidence that the largest prime needed in this table is (logn)1+O(1); assuming the Extended Riemann Hypothesis, primes up to (logn)2+O(1) suffice. The table can be computed in time roughly proportional to the largest prime it contains.

We also present computational results indicating that our sieve algorithms perform extremely well in practice.

Key words

Perfect powers Number theoretic algorithms Riemann hypothesis Newton's method Sieve algorithms Parallel algorithms Average-case analysis 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. [1]
    E. Bach. How to generate factored random numbers.SIAM J. Comput.,2:179–193, 1988.Google Scholar
  2. [2]
    E. Bach, G. Miller and J. Shallit. Sums of Divisors, perfect numbers, and factoring.SIAM J. Comput.,4:1143–1154, 1986.Google Scholar
  3. [3]
    E. Bach and J. Shallit. Factoring with cyclotomic polynomials.Math. Comp.,52(185):201–219, 1989.Google Scholar
  4. [4]
    P. W. Beame, S. A. Cook and H. J. Hoover. Log depth circuits for division and related problems.SIAM J. Comput.,15:994–1003, 1986.Google Scholar
  5. [5]
    R. P. Brent. Multiple precision zero-finding methods and the complexity of elementary function evaluation. In J. F. Traub, editor,Analytical Computational Complexity, pp. 151–176. Academic Press, New York, 1976.Google Scholar
  6. [6]
    A. Cobham. The recognition problem for the set of perfect squares. InProceedings of the 7th Annual Symposium on Switching and Automata Theory, pp. 78–87, 1966.Google Scholar
  7. [7]
    G. E. Collins. Computing multiplicative inverses inGF(p).Math. Comp.,23:197–200, 1969.Google Scholar
  8. [8]
    H. Davenport.Multiplicative Number Theory. Springer-Verlag, New York, 1980.Google Scholar
  9. [9]
    J. Dixon. Asymptotically fast factorization of integers.Math. Comp.,36(153):255–260, 1981.Google Scholar
  10. [10]
    S. Goldwasser and J. Kilian. Almost all primes can be quickly certified. InProceedings of the 18th Annual ACM Symposium on Theory of Computing, pp. 316–329, 1986.Google Scholar
  11. [11]
    S. W. Golomb. A new arithmetic function of combinatorial significance.J. Number Theory,5:218–223, 1973.Google Scholar
  12. [12]
    J. L. Hafner and K. S. McCurley. On the distribution of running times of certain integer factoring algorithms.J. Algorithms,10(4):531–556, 1989.Google Scholar
  13. [13]
    G. H. Hardy and E. M. Wright.An Introduction to the Theory of Numbers, Oxford University Press, Oxford, 5th edition. 1979.Google Scholar
  14. [14]
    K. Ireland and M. Rosen.A Classical Introduction to Modern Number Theory. Springer-Verlag, New York, 1982.Google Scholar
  15. [15]
    W. B. Jurkat and H.-E. Richert. An improvement of Selberg's sieve method I.Acta. Arith.,11:217–240, 1965.Google Scholar
  16. [16]
    R. Karp and V. Ramachandran. Parallel algorithms for shared memory machines. In J. van Leeuwen, editor,Algorithms and Complexity, Chapter 17, pp. 871–941. Handbook of Theoretical Computer Science Series, Volume A. Elsevier, Amsterdam, and MIT Press, Cambridge, MA, 1990.Google Scholar
  17. [17]
    D. E. Knuth.The Art of Computer Programming: Seminumerical Algorithms, Volume 2, 2nd edition. Addison-Wesley, Reading, MA. 1981.Google Scholar
  18. [18]
    D. E. Knuth and L. Trabb Pardo. Analysis of a simple factorization algorithm.Theoret. Comput. Sci.,3:321–348, 1976.Google Scholar
  19. [19]
    A. K. Lenstra, H. W. Lenstra, Jr., M. S. Manasse and J. M. Pollard. The number field sieve. InProceedings of the 22nd Annual ACM Symposium on Theory of Computing, pp. 564–572, 1990.Google Scholar
  20. [20]
    H. W. Lenstra, Jr. Factoring integers with elliptic curves.Ann. of Math.,126:649–673, 1987.Google Scholar
  21. [21]
    V. Miller. Private communication, 1989.Google Scholar
  22. [22]
    C. A. Neff. Specified precision polynomial root isolation is in NC. InProceedings of 31st Annual IEEE Symposium on Foundations of Computer Science, pp. 152–162, 1990.Google Scholar
  23. [23]
    V. Pan. Fast and efficient algorithms for sequential and parallel evaluation of polynomial zeros and of matrix polynomials. InProceedings of the 26th Annual IEEE Symposium on Foundations of Computer Science, pp. 522–531, 1985.Google Scholar
  24. [24]
    J. M. Pollard. Theorems on factorization and primality testing.Math. Proc. Cambridge Philos. Soc.,76:521–528, 1974.Google Scholar
  25. [25]
    C. Pomerance. Fast, rigorous factorization and discrete logarithm algorithms. In D. S. Johnson, A. Nishizeke, A. Nozaki, and H. S. Wilf, editors,Discrete Algorithms and Complexity: Proceedings of the Japan-US Joint Seminar, pp. 119–143. Perspectives in Computing Series, Volume 15, Academic Press, Boston. 1987.Google Scholar
  26. [26]
    P. Pritchard. Fast compact prime number sieves (among others).J. Algorithms,4:332–344, 1983.Google Scholar
  27. [27]
    J. B. Rosser and L. Schoenfeld. Approximate formulas for some functions of prime numbers.Illinois J. Math.,6:64–94, 1962.Google Scholar
  28. [28]
    J. Shallit. Course Notes for Number Theory and Algorithms. Dartmouth College, 1989.Google Scholar
  29. [29]
    V. Shoup. On the deterministic complexity of factoring polynomials over finite fields.Inform. Process. Lett.,33:261–267, 1990.Google Scholar
  30. [30]
    E. C. Titchmarsh. A divisor problem.Rend. Circ. Mat. Palermo,54:414–429, 1930.Google Scholar
  31. [31]
    S. S. Wagstaff, Jr., Greatest of the least primes in arithmetic progressions having a certain modulus.Math. Comp.,33:1073–1080, 1979.Google Scholar

Copyright information

© Springer-Verlag New York Inc. 1993

Authors and Affiliations

  • Eric Bach
    • 1
  • Jonathan Sorenson
    • 2
  1. 1.Computer Sciences DepartmentUniversity of Wisconsin-MadisonMadisonUSA
  2. 2.Department of Mathematics and Computer ScienceButler UniversityIndianapolisUSA

Personalised recommendations