Euler's criterion


In number theory, Euler's criterion is a formula for determining whether an integer is a quadratic residue modulo a prime. Precisely,
Let p be an odd prime and a be an integer coprime to p. Then
Euler's criterion can be concisely reformulated using the Legendre symbol:
The criterion first appeared in a 1748 paper by Leonhard Euler.

Proof

The proof uses the fact that the residue classes modulo a prime number are a field. See the article prime field for more details.
Because the modulus is prime, Lagrange's theorem applies: a polynomial of degree can only have at most roots. In particular, has at most 2 solutions for each. This immediately implies that besides 0, there are at least distinct quadratic residues modulo : each of the possible values of can only be accompanied by one other to give the same residue.
In fact, This is because
So, the distinct quadratic residues are:
As is coprime to, Fermat's little theorem says that
which can be written as
Since the integers mod form a field, for each, one or the other of these factors must be zero.
Now if is a quadratic residue,,
So every quadratic residue makes the first factor zero.
Applying Lagrange's theorem again, we note that there can be no more than values of that make the first factor zero. But as we noted at the beginning, there are at least distinct quadratic residues . Therefore, they are precisely the residue classes that make the first factor zero. The other residue classes, the nonresidues, must make the second factor zero, or they would not satisfy Fermat's little theorem. This is Euler's criterion.

Alternative proof

This proof only uses the fact that any congruence has a unique solution provided does not divide. It follows from this fact that all nonzero remainders modulo the square of which isn't congruent to can be grouped into pairs according to the rule that the product of the members of each pair is congruent to modulo . If is a quadratic nonresidue, this is simply a regrouping of all nonzero residues into pairs, hence we conclude that. If is a quadratic residue, exactly two remainders were not among those paired, and such that. If we pair those two absent remainders together, their product will be rather than, whence in this case. In summary, considering these two cases we have demonstrated that for we have, It remains to substitute into this formula to obtain at once Wilson's theorem, Euler's criterion, and Fermat's little theorem.

Examples

Example 1: Finding primes for which a is a residue
Let a = 17. For which primes p is 17 a quadratic residue?
We can test prime ps manually given the formula above.
In one case, testing
p = 3, we have 17/2 = 171 ≡ 2 ≡ −1, therefore 17 is not a quadratic residue modulo 3.
In another case, testing
p = 13, we have 17/2 = 176 ≡ 1, therefore 17 is a quadratic residue modulo 13. As confirmation, note that 17 ≡ 4, and 22 = 4.
We can do these calculations faster by using various modular arithmetic and Legendre symbol properties.
If we keep calculating the values, we find:
Example 2: Finding residues given a prime modulus p '
Which numbers are squares modulo 17 ?
We can manually calculate it as:
So the set of the quadratic residues modulo 17 is. Note that we did not need to calculate squares for the values 9 through 16, as they are all negatives of the previously squared values, so 922 = 64 ≡ 13 ).
We can find quadratic residues or verify them using the above formula. To test if 2 is a quadratic residue modulo 17, we calculate 2/2 = 28 ≡ 1, so it is a quadratic residue. To test if 3 is a quadratic residue modulo 17, we calculate 3/2 = 38 ≡ 16 ≡ −1, so it is not a quadratic residue.
Euler's criterion is related to the Law of quadratic reciprocity.

Applications

In practice, it is more efficient to use an extended variant of Euclid's algorithm to calculate the Jacobi symbol. If is an odd prime, this is equal to the Legendre symbol, and decides whether is a quadratic residue modulo.
On the other hand, since the equivalence of to the Jacobi symbol holds for all odd primes, but not necessarily for composite numbers, calculating both and comparing them can be used as a primality test, specifically the Solovay-Strassen primality test. Composite numbers for which the congruence holds for a given are called Euler–Jacobi pseudoprimes to base.