Solovay-Strassen test
It is known that an odd number is prime if and only if for every such that we have
(1) |
where is the Jacobi symbol. (The only if part is obvious; the if part follows from Theorem 1.) From this we can derive the following algorithm
.
- 1.
Choose a random number between and .
- 2.
Check if (for example using the Euclidean algorithm
). If it is not, then is not prime and is a divisor
of .
- 3.
Check if Equation (1) holds. If it does not, then is not prime. Otherwise is a candidate for primality.
By repeating this algorithm we can increase the chance that the result is correct. In order to estimate the probability of error, we make use of Theorem 1, which says that every independent iteration of the algorithm has a chance of at most of being wrong. Hence, after iterations there is at most a chance of getting a wrong result.
Theorem 1.
Let be an odd composite integer. Then at least half of theelements of do not satisfy Equation (1).
Proof.
It suffices to exhibit one element which does not satisfy Equation (1). Indeed, if there exists one such element, then the set ofall elements which do satisfy Equation (1) forms a proper subgroup of , from which weconclude that the elements satisfying Equation (1) number no more than half of the elementsof .
We consider separately the cases where is squarefree and notsquarefree. If is squarefree, let be a prime dividing andlet be a quadratic non-residue mod . Using the ChineseRemainder Theorem
, choose an integer such that:
The Jacobi symbol is given by
We will assume that and derivea contradiction. The equation implies that .However, since , we must have, so that , which is a contradiction.
Now suppose that is not squarefree. Let be a prime such that, and set . By the binomial theorem,we have
so the multiplicative order of is equal to , and hencein particular , since . On theother hand,
so does not satisfy Equation (1).∎