## Abstract

A positive integer*n* is a perfect power if there exist integers*x* and*k*, both at least 2, such that*n=x*^{k}. The usual algorithm to recognize perfect powers computes approximate*kth* roots for*k≤log*_{2}*n*, and runs in time O(log^{3}*n* log log log*n*).

First we improve this worst-case running time to*O*(log^{3}*n*) by using a modified Newton's method to compute approximate*k*th roots. Parallelizing this gives anNC^{2} algorithm.

Second, we present a sieve algorithm that avoids*k*th-root computations by seeing if the input*n* is a perfect*k*th power modulo small primes. If*n* is chosen uniformly from a large enough interval, the average running time is*O*(log^{2}*n*).

Third, we incorporate trial division to give a sieve algorithm with an average running time of*O*(log^{2} n/log^{2} log*n*) and a median running time of*O*(log*n*).

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 (log*n*)^{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## Preview

Unable to display preview. Download preview PDF.

### References

- [1]
- [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]E. Bach and J. Shallit. Factoring with cyclotomic polynomials.
*Math. Comp.*,**52**(185):201–219, 1989.Google Scholar - [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]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]A. Cobham. The recognition problem for the set of perfect squares. In
*Proceedings of the 7th Annual Symposium on Switching and Automata Theory*, pp. 78–87, 1966.Google Scholar - [7]G. E. Collins. Computing multiplicative inverses in
*GF(p)*.*Math. Comp.*,**23**:197–200, 1969.Google Scholar - [8]H. Davenport.
*Multiplicative Number Theory*. Springer-Verlag, New York, 1980.Google Scholar - [9]J. Dixon. Asymptotically fast factorization of integers.
*Math. Comp.*,**36**(153):255–260, 1981.Google Scholar - [10]S. Goldwasser and J. Kilian. Almost all primes can be quickly certified. In
*Proceedings of the 18th Annual ACM Symposium on Theory of Computing*, pp. 316–329, 1986.Google Scholar - [11]S. W. Golomb. A new arithmetic function of combinatorial significance.
*J. Number Theory*,**5**:218–223, 1973.Google Scholar - [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]G. H. Hardy and E. M. Wright.
*An Introduction to the Theory of Numbers*, Oxford University Press, Oxford, 5th edition. 1979.Google Scholar - [14]K. Ireland and M. Rosen.
*A Classical Introduction to Modern Number Theory*. Springer-Verlag, New York, 1982.Google Scholar - [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]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]D. E. Knuth.
*The Art of Computer Programming: Seminumerical Algorithms*, Volume 2, 2nd edition. Addison-Wesley, Reading, MA. 1981.Google Scholar - [18]D. E. Knuth and L. Trabb Pardo. Analysis of a simple factorization algorithm.
*Theoret. Comput. Sci.*,**3**:321–348, 1976.Google Scholar - [19]A. K. Lenstra, H. W. Lenstra, Jr., M. S. Manasse and J. M. Pollard. The number field sieve. In
*Proceedings of the 22nd Annual ACM Symposium on Theory of Computing*, pp. 564–572, 1990.Google Scholar - [20]H. W. Lenstra, Jr. Factoring integers with elliptic curves.
*Ann. of Math.*,**126**:649–673, 1987.Google Scholar - [21]V. Miller. Private communication, 1989.Google Scholar
- [22]C. A. Neff. Specified precision polynomial root isolation is in NC. In
*Proceedings of 31st Annual IEEE Symposium on Foundations of Computer Science*, pp. 152–162, 1990.Google Scholar - [23]V. Pan. Fast and efficient algorithms for sequential and parallel evaluation of polynomial zeros and of matrix polynomials. In
*Proceedings of the 26th Annual IEEE Symposium on Foundations of Computer Science*, pp. 522–531, 1985.Google Scholar - [24]J. M. Pollard. Theorems on factorization and primality testing.
*Math. Proc. Cambridge Philos. Soc.*,**76**:521–528, 1974.Google Scholar - [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]P. Pritchard. Fast compact prime number sieves (among others).
*J. Algorithms*,**4**:332–344, 1983.Google Scholar - [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]J. Shallit. Course Notes for Number Theory and Algorithms. Dartmouth College, 1989.Google Scholar
- [29]V. Shoup. On the deterministic complexity of factoring polynomials over finite fields.
*Inform. Process. Lett.*,**33**:261–267, 1990.Google Scholar - [30]
- [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