WOLFRAM|DEMONSTRATIONS PROJECT

Pratt Certificates of Primality

​
p
3
A prime number
p
can be proved prime by exhibiting all the prime factors of
p-1
together with a witness
w
such that
p-1
w
≡1(modp)
but
(p-1)/q
w
≢1(modp)
for each prime divisor
q
of
p-1
. The primes
q
are then proved prime in the same way, except that 2 is assumed to be prime without proof. This recursive construction has a tree structure, which is shown here. These ideas prove that the prime numbers lie in the complexity class NP. If the input number is not prime, the next prime is used.