Primality tests
One way to prove that a given number is prime is to find one of its primitive roots.
Choose a random between and .
If , then is not prime. Better yet, the greatest common divisor allows us to partially factor .
By Fermat's little theorem, we know that . If this is not so, then definitely is not prime.
Furthermore, when is an odd number, we must have either or .
Now, it can be shown that is a primitive root modulo if, for every prime divisor of , we have . If satisfies these conditions then the order of modulo must be , and thus must be prime.
If not, try another .
These exist composite numbers, called Carmichael numbers, for which for all which are relatively prime to . For these numbes, .
The Miller-Rabin primality test
Goal: to test if the odd number , with , is a prime number or not.
Result of the test: either is not prime or it may be prime (a probable primer number); in the second case, the probability that the test fails to identify a composite number is at most 0.25.
How it is done (to increase confidence on the result, do steps 2 to 6 several times):
Let be written as , with an odd number (so is as large as possible).
Select at random an integer uniformly distributed in the interval .
If , then is definitely a composite number.
Compute . If or then is a probale prime.
Otherwise, for , compute . If then is a probable prime.
Finally, if we get here, say that is definitely a composite number (because Fermat's little theorem failed because ).
The composite numbers that pass this test (meaning that the algorithm above says that they are probable primes) for a given are called base- strong pseudo-primes.
Last updated