Gauss's lemma in number theory gives a condition for an integer to be a quadratic residue. Although it is not useful computationally, it has theoretical significance, being involved in some proofs of quadratic reciprocity. It made its first appearance in Carl Friedrich Gauss's third proof (1808) of quadratic reciprocity and he proved it again in his fifth proof (1818). Statement of the lemma For any odd prime let be an integer that is coprime to . Consider the integers and their least positive residues modulo . These residues are all distinct, so there are ( of them. Let be the number of these residues that are greater than . Then where is the Legendre symbol. Example Taking = 11 and = 7, the relevant sequence of integers is 7, 14, 21, 28, 35. After reduction modulo 11, this sequence becomes 7, 3, 10, 6, 2. Three of these integers are larger than 11/2 (namely 6, 7 and 10), so = 3. Correspondingly Gauss's lemma predicts that This is indeed correct, because 7 is not a quadratic residue modulo 11. The above sequence of residues 7, 3, 10, 6, 2 may also be written −4, 3, −1, −5, 2. In this form, the integers larger than 11/2 appear as negative numbers. It is also apparent that the absolute values of the residues are a permutation of the residues 1, 2, 3, 4, 5. Proof A fairly simple proof, reminiscent of one of the simplest proofs of Fermat's little theorem, can be obtained by evaluating the product modulo p in two different ways. On one hand it is equal to The second evaluation takes more work. If is a nonzero residue modulo , let us define the "absolute value" of to be Since counts those multiples which are in the latter range, and since for those multiples, is in the first range, we have Now observe that the values are distinct for . Indeed, we have because is coprime to . This gives = , since and are positive least residues. But there are exactly of them, so their values are a rearrangement of the integers . Therefore, Comparing with our first evaluation, we may cancel out the nonzero factor and we are left with This is the desired result, because by Euler's criterion the left hand side is just an alternative expression for the Legendre symbol . Applications Gauss's lemma is