The Legendre symbol is when is a nonzero square modulo the odd prime , when it is not a square, and when . For the coprime case, Euler's criterion states
Write . For , the balanced residues are nonzero and their absolute values lie in . If , then . Cancel . The plus sign forces ; the minus sign would require , impossible because . Thus the absolute residues form a permutation of . If exactly are negative, multiplying gives
Since does not divide , cancellation and Euler's criterion prove Gauss's lemma:
The two signs are distinct modulo the odd prime, so this congruence identifies the integer symbol itself.
For , the balanced representative of is negative precisely when , giving . Checking the four odd residue classes modulo eight gives even for and odd for . Hence
This is the quadratic character of two obtained from the lemma.
Let and . If a prime divides , then is odd and cannot divide . Moreover
so has an explicit nonzero square root modulo . The criterion just proved forces every prime divisor of into the classes or modulo eight. But : if all its prime factors were modulo eight, their product, with multiplicities, would also be . Thus at least one prime divisor is modulo eight. No listed divides , because . This always produces another such prime, proving infinitely many primes are congruent to seven modulo eight, the Euclid proof for infinitely many primes congruent to seven modulo eight.
Suppose only finitely many primes are congruent to modulo , and set
Then
If an odd prime divides , then , so part (a) gives
Since their product is modulo , at least one prime divisor is modulo to an odd power. Yet no listed divides , because gives
This produces a new prime congruent to modulo , a contradiction. Hence
This is the Euclid proof for infinitely many primes congruent to seven modulo eight.