10.12.2012 Views

Prime Numbers

Prime Numbers

Prime Numbers

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

244 Chapter 5 EXPONENTIAL FACTORING ALGORITHMS<br />

Such a suitable D is found very easily. Take x0 =<br />

√ <br />

n − n2/3 ,sothatif<br />

d = n − x 2 0,thenn 2/3 ≤ d 1 that has<br />

no prime factors below 3n 1/3 . This algorithm decides whether n is prime or<br />

composite, the algorithm giving in the composite case the prime factorization<br />

of n. (Note that any nontrivial factorization must be the prime factorization,<br />

since each prime factor of n exceeds the cube root of n.)<br />

1. [Square test]<br />

If n is a square, say p 2 , return the factorization p · p;<br />

// A number may be tested for squareness via Algorithm 9.2.11.<br />

2. [Side factorization]<br />

√ 2 d = n − n − n2/3 ; // Thus, each prime factor of n is > 2 √ d.<br />

if (gcd(n, d) > 1) return the factorization gcd(n, d) · (n/ gcd(n, d));<br />

By trial division, find the complete prime factorization of d;<br />

3. [Congruences] <br />

for(1 ≤ a ≤ 2 <br />

d/3 ) {<br />

Using the prime factorization of d and a method from Section 2.3.2 find<br />

the solutions u1,...,ut of the congruence u2 ≡ 4an (mod 4d);<br />

for(1 ≤ i ≤ t) { // If t =0this loop is not executed.<br />

For all integers u with 0 ≤ u ≤ 2 √ an, u ≡ ui (mod 4d), use<br />

Algorithm 9.2.11 to see whether (4an − u2 )/4d is a square;<br />

If such a square is found, say v2 ,andu≡ ±2x0v (mod 2n), goto<br />

[gcd computation];<br />

}<br />

}<br />

return “n is prime”;<br />

4. [gcd computation]<br />

g =gcd(2x0v − u, n);<br />

return the factorization g · (n/g);<br />

// The factorization is nontrivial and the factors are primes.<br />

Theorem 5.6.4. Consider a procedure that on input of an integer n>1<br />

first removes from n any prime factor up to 3n 1/3 (via trial division), and<br />

if this does not completely factor n, the unfactored portion is used as the<br />

input in Algorithm 5.6.3. In this way, the complete prime factorization of n

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

Saved successfully!

Ooh no, something went wrong!