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 wordsPerfect powers Number theoretic algorithms Riemann hypothesis Newton's method Sieve algorithms Parallel algorithms Average-case analysis
Unable to display preview. Download preview PDF.
- E. Bach. How to generate factored random numbers.SIAM J. Comput.,2:179–193, 1988.Google Scholar
- E. Bach, G. Miller and J. Shallit. Sums of Divisors, perfect numbers, and factoring.SIAM J. Comput.,4:1143–1154, 1986.Google Scholar
- E. Bach and J. Shallit. Factoring with cyclotomic polynomials.Math. Comp.,52(185):201–219, 1989.Google Scholar
- 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
- 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
- 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
- G. E. Collins. Computing multiplicative inverses inGF(p).Math. Comp.,23:197–200, 1969.Google Scholar
- H. Davenport.Multiplicative Number Theory. Springer-Verlag, New York, 1980.Google Scholar
- J. Dixon. Asymptotically fast factorization of integers.Math. Comp.,36(153):255–260, 1981.Google Scholar
- 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
- S. W. Golomb. A new arithmetic function of combinatorial significance.J. Number Theory,5:218–223, 1973.Google Scholar
- 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
- G. H. Hardy and E. M. Wright.An Introduction to the Theory of Numbers, Oxford University Press, Oxford, 5th edition. 1979.Google Scholar
- K. Ireland and M. Rosen.A Classical Introduction to Modern Number Theory. Springer-Verlag, New York, 1982.Google Scholar
- W. B. Jurkat and H.-E. Richert. An improvement of Selberg's sieve method I.Acta. Arith.,11:217–240, 1965.Google Scholar
- 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
- D. E. Knuth.The Art of Computer Programming: Seminumerical Algorithms, Volume 2, 2nd edition. Addison-Wesley, Reading, MA. 1981.Google Scholar
- D. E. Knuth and L. Trabb Pardo. Analysis of a simple factorization algorithm.Theoret. Comput. Sci.,3:321–348, 1976.Google Scholar
- 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
- H. W. Lenstra, Jr. Factoring integers with elliptic curves.Ann. of Math.,126:649–673, 1987.Google Scholar
- V. Miller. Private communication, 1989.Google Scholar
- 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
- 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
- J. M. Pollard. Theorems on factorization and primality testing.Math. Proc. Cambridge Philos. Soc.,76:521–528, 1974.Google Scholar
- 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
- P. Pritchard. Fast compact prime number sieves (among others).J. Algorithms,4:332–344, 1983.Google Scholar
- J. B. Rosser and L. Schoenfeld. Approximate formulas for some functions of prime numbers.Illinois J. Math.,6:64–94, 1962.Google Scholar
- J. Shallit. Course Notes for Number Theory and Algorithms. Dartmouth College, 1989.Google Scholar
- V. Shoup. On the deterministic complexity of factoring polynomials over finite fields.Inform. Process. Lett.,33:261–267, 1990.Google Scholar
- E. C. Titchmarsh. A divisor problem.Rend. Circ. Mat. Palermo,54:414–429, 1930.Google Scholar
- S. S. Wagstaff, Jr., Greatest of the least primes in arithmetic progressions having a certain modulus.Math. Comp.,33:1073–1080, 1979.Google Scholar