Quadratic Residue — Definition, Formula & Examples
A quadratic residue modulo is an integer for which the equation has a solution. In other words, is a quadratic residue mod if some integer squared gives when you divide by and take the remainder.
Let be a positive integer and an integer with . Then is called a quadratic residue modulo if there exists an integer such that . If no such exists, is called a quadratic nonresidue modulo .
Key Formula
Where:
- = An integer not divisible by p
- = An odd prime
How It Works
To check whether is a quadratic residue mod , compute for each from to and see if appears among the results. For an odd prime , exactly of the integers are quadratic residues. Euler's criterion provides a shortcut when is prime: is a quadratic residue mod if and only if . The Legendre symbol encodes this classification, equaling for residues and for nonresidues.
Worked Example
Problem: Determine all quadratic residues modulo 7.
Compute squares: Square each integer from 1 to 6 and reduce modulo 7.
Collect distinct results: The distinct values obtained are 1, 2, and 4. These are the quadratic residues mod 7. Notice there are exactly (7−1)/2 = 3 of them.
Identify nonresidues: The remaining values 3, 5, and 6 are quadratic nonresidues mod 7, since no square produces them.
Answer: The quadratic residues modulo 7 are , and the quadratic nonresidues are .
Why It Matters
Quadratic residues are central to the law of quadratic reciprocity, one of the landmark theorems in number theory. They also underpin modern cryptographic protocols such as the Goldwasser–Micali encryption scheme, where security relies on the difficulty of distinguishing residues from nonresidues modulo a large composite number.
Common Mistakes
Mistake: Including 0 as a quadratic residue when working modulo a prime p.
Correction: By convention, quadratic residues are drawn from integers coprime to the modulus. Since , zero is excluded from the classification.
