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.

178 Chapter 4 PRIMALITY PROVING<br />

Since n is prime, this must be a trivial factorization of n, thatis,<br />

c1 + tF −|u| =0,<br />

which implies c4 = t. Butc4 ≥ F ≥ n 3/10 ≥ 214 3/10 > 5 ≥ t, a contradiction.<br />

So if (1) fails, n must be composite. It is obvious that if n is prime, then (2)<br />

holds. ✷<br />

As with Theorem 4.1.5, if Theorem 4.1.6 is to be used as a primality<br />

test, one should use Algorithm 9.2.11 as a subroutine to recognize squares. In<br />

addition, one should use Newton’s method or a divide and conquer strategy<br />

to search for integral roots of the cubic polynomial in condition (2) of the<br />

theorem. We next embody Theorems 4.1.3-4.1.6 in one algorithm.<br />

Algorithm 4.1.7 (The n − 1 test). Supposewehaveanintegern ≥ 214 and<br />

that (4.2) holds with F ≥ n 3/10 . This probabilistic algorithm attempts to decide<br />

whether n is prime (YES) or composite (NO).<br />

1. [Pocklington test]<br />

Choose random a ∈ [2,n− 2];<br />

if(a n−1 ≡ 1(modn)) return NO; // n is composite.<br />

for(prime q|F ) {<br />

g =gcd (a (n−1)/q mod n) − 1,n ;<br />

if(1

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

Saved successfully!

Ooh no, something went wrong!