2.3.5 Pratt prime number test

The Pratt prime number test is very similar to the Lucas prime number test. Both are based on the same theorem:

A number p>1 is prime, exactly when: There is a number r with 1<r<p and
1) rp-1 mod p = 1
2) for all prime factors q of p-1 applies: r(p-1)/q mod p 1.

A witness for p beeing prime is build as follows: Z(p) = (r;q1; q2; ...; qn).

To check if all qi are really prime, the formula is used recursively.

Z(2) = (1)

Z(p) = (r), if p-1 is prime

Z(p) = (r; q1, Z(q1); q2, Z(q2); ...; qn, Z(qn)), else.

The result is this sequence (r, q1, Z(q11, Z(q11),...), ..., qn, Z(qn1, Z(qn1), ...). For all elements the conditions of the above theorem have to be tested.

The Pratt algorithm guesses this sequence no deterministicly.

Example:

For p=31 the algorithm guesses: Z(31) = (3; 2, (1), 3, (2; 2, (1)), 5, (2; 2, (1), 2, (1))

or in a diffrent view:

r=3

 

 

q1=2

Z(q1)=1

 

q2=3

r2=2

 

 

q21=2

Z(q21)=1

q3=5

r3=2

 

q31=2

Z(q31)=1

 

q32=2

Z(q32)=1

Then it verifies:

331-1 = 1 mod 31

23-1 = 1 mod 3

25-1 = 1 mod 5

330/2 # 1 mod 31

22/2 # 1 mod 3

24/2 # 1 mod 5

330/3 # 1 mod 31

 

 

330/5 # 1 mod 31

 

 

Applet Pratt prime number test:

Source code:
Pratt.java � GUI
Prime.java � prime number functions

2.4.1 AKS Test