10.12.2012 Views

Prime Numbers

Prime Numbers

Prime Numbers

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

238 Chapter 5 EXPONENTIAL FACTORING ALGORITHMS<br />

larger than B. After searching through the exponents M(1),M(2),...,M(B),<br />

we next search through the exponents QM(B), where Q runs over the<br />

primes in the interval (B,B ′ ]. This then has the chance of uncovering<br />

those primes p|n with p − 1 = Qu, where Q is a prime in (B,B ′ ] and<br />

u|M(B). It is particularly easy to traverse the various exponents QM(B).<br />

Suppose the sequence of primes in (B,B ′ ]isQ1 < Q2 < ··· . Note that<br />

2 Q1M(B) mod n may be computed from 2 M(B) mod n in O(ln Q1) steps. For<br />

2 Q2M(B) mod n, we multiply 2 Q1M(B) mod n by 2 (Q2−Q1)M(B) mod n, then<br />

by 2 (Q3−Q2)M(B) mod n to get 2 Q3M(B) mod n, and so on. The differences<br />

Qi+1−Qi are all much smaller than the Qi’s themselves, and for various values<br />

d of these differences, the residues 2 dM(B) mod n can be precomputed. Thus,<br />

if B ′ > 2B, say, the amortized cost of computing all of the 2 QiM(B) mod n<br />

is just one modular multiplication per Qi. If we agree to spend just as much<br />

time doing the second stage as the basic p − 1 method, then we may take B ′<br />

much larger than B, perhaps as big as B ln B.<br />

There are many interesting issues pertaining to the second stage, such as<br />

means for further acceleration, birthday paradox manifestations, and so on.<br />

See [Montgomery 1987, 1992a], [Crandall 1996a], and Exercise 5.9 for some of<br />

these issues.<br />

We shall see that the basic idea of the Pollard p−1 method is revisited with<br />

the Lenstra elliptic curve method (ECM) for factoring integers (see Section<br />

7.4).<br />

5.5 Polynomial evaluation method<br />

Suppose the function F (k, n) =k! modn were easy to evaluate. Then a great<br />

deal of factoring and primality testing would also be easy. For example, the<br />

Wilson–Lagrange theorem (Theorem 1.3.6) says that an integer n>1isprime<br />

if and only if F (n − 1,n)=n − 1. Alternatively, n>1 is prime if and only if<br />

F (⌈ √ n⌉ ,n) is coprime to n. Further, we could factor almost as easily: Carry<br />

out a binary search for the least positive integer k with gcd(F (k, n),n) > 1—<br />

this k, of course, will be the least prime factor of n.<br />

As outlandish as this idea may seem, there is actually a fairly fast<br />

theoretical factoring algorithm based on it, an algorithm that stands as the<br />

fastest deterministic rigorously analyzed factoring algorithm of which we<br />

know. This is the Pollard–Strassen polynomial evaluation method; see [Pollard<br />

1974] and [Strassen 1976].<br />

Theideaisasfollows.LetB = n 1/4 and let f(x) be the polynomial<br />

x(x − 1) ···(x − B + 1). Then f(jB) =(jB)!/((j − 1)B)! for every positive<br />

integer j, so that the least j with gcd(f(jB),n) > 1 isolates the least prime<br />

factor of n in the interval ((j − 1)B,jB]. Once we know this, if the gcd is in<br />

the stated interval, it is the least prime factor of n, and if the gcd is larger<br />

than jB, we may sequentially try the members of the interval as divisors of<br />

n, the first divisor found being the least prime divisor of n. Clearly, this last<br />

calculation takes at most B arithmetic operations with integers the size of n;<br />

that is, it is O(n 1/4 ). But what of the earlier steps? If we could compute each

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!