Suppose is a quadratic nonresidue. On the nonzero residue classes modulo , define the involution
It is an involution because . A fixed point would satisfy , which is excluded by the quadratic nonresidue hypothesis. Thus it partitions the classes into disjoint pairs , each with product . Consequently
Now evaluate the same product by pairing every class with its own modular inverse. The only classes equal to their modular inverses solve and hence are and . All other pairs have product one. The complete product is therefore , so
Together with the preceding part, this is Euler's criterion; the pairing argument establishes the converse without assuming it.
For the odd prime , the Fermat-Euler theorem gives . Therefore the residue class obeys . Since a prime number dividing a product divides one of its factors,
If is a quadratic residue, choose with . Then is nonzero modulo , and Fermat's little theorem gives
This proves the quadratic residue direction of Euler's criterion.
For an odd prime , the Legendre symbol is if , if is a nonzero square modulo , and otherwise. Euler's criterion states
If both sides vanish. Otherwise write for a primitive root . The squares are precisely the even powers of , while has order two and therefore equals . Hence , proving the criterion and the useful special case .
For odd , . Every prime divisor of this number is odd, and , so . Euler's criterion forces , hence or . A product of such primes can be only if a prime occurs to an odd power.
Suppose the primes were . Choose the odd integer (or for an empty list). None of these primes divides , since the latter is modulo each . Yet the preceding argument gives a prime divisor , outside the list. This contradiction proves infinitely many primes congruent to modulo .
For an odd prime number , the Legendre symbol is zero when , one when is a nonzero quadratic residue modulo , and minus one otherwise. The number-theoretic Gauss lemma says that, for , , where counts those least positive residues of exceeding .
For , the residues are simply , so . Examining the four odd residue classes modulo eight gives
Now and is odd. The multiplicative order of divides but not . Since is a power of two, every proper divisor of divides , whence . Lagrange's theorem for finite groups gives . Because , this implies , so the supplementary law just proved gives . By Euler's criterion, , and consequently . Therefore
Gauss lemma states that if and of the least positive residues of
exceed , then .
To prove it, replace each residue exceeding by its negative, obtaining numbers in . No two of them are equal modulo : such an equality would give , hence in the allowed range. They therefore permute , and multiplication gives
Cancel the nonzero factorial and apply Euler's criterion to obtain the lemma.
For , all least positive residues exceed . Hence the first supplementary law for quadratic reciprocity is
Euler's criterion states that for an odd prime number and ,
where the right-hand side is the Legendre symbol.
Let be a primitive root modulo . Its multiplicative order is , so . This power has square , and the only roots of modulo the odd prime are . Therefore
Euler's criterion now gives , so every primitive root is a quadratic nonresidue.
Now let be a Fermat prime, with . The number of primitive roots modulo is
There are also exactly quadratic nonresidues. Since every primitive root is a nonresidue, these equally large sets coincide. Thus every quadratic nonresidue modulo is a primitive root, as summarized by Quadratic nonresidues modulo a Fermat prime.
Finally, and . Quadratic reciprocity therefore gives
Hence is a quadratic nonresidue modulo , and consequently
The Solovay-Strassen primality test samples unit bases and rejects an odd candidate as composite when it finds an Euler witness. Every prime passes every base by Euler's criterion, while an odd composite passes a random base with probability at most one half.