Quadratic Residue Calculator
Find out whether a is a square modulo n, list every x with x² ≡ a (mod n), and see the squares on a modular clock.
Your Values
Visualization
Results
Step-by-Step Solution
How Quadratic Residue Calculator Works?
The quadratic residue calculator reduces a modulo n, applies Euler’s criterion when n is an odd prime, and squares every x from 0 to n − 1 to list all solutions of x² ≡ a (mod n).
- Enter a and the modulus n
- Reduce a mod n
- Test a^((n−1)/2) mod n for odd prime n
- Square every x from 0 to n − 1
- Collect the x values with x² ≡ a
- Draw the modular clock
The clock places 0 to n − 1 around a circle and draws a chord from each x to x² mod n. Chords that land on a are highlighted, and the calculator draws the clock for moduli up to 96.
Quadratic Residue Formula
The quadratic residue formula is x² ≡ a (mod n), and Euler’s criterion for an odd prime p states that a^((p−1)/2) ≡ (a/p) (mod p).
- (a/p) = 1
- a is a quadratic residue
- (a/p) = −1
- a is a non-residue
- (a/p) = 0
- p divides a
- (p − 1)/2
- number of non-zero residues mod an odd prime p
Worked Example: Is 10 a Square mod 13?
- 6² = 36 = 2 × 13 + 10.
- 7² = 49 = 3 × 13 + 10.
- 10⁶ ≡ 1 (mod 13), so Euler’s criterion gives (10/13) = 1.
- Yes: x ≡ 6 or 7 (mod 13).
Carl Friedrich Gauss proved the law of quadratic reciprocity in 1796 and published it in Disquisitiones Arithmeticae in 1801: (p/q)(q/p) = (−1)^((p−1)/2 · (q−1)/2) for distinct odd primes p and q.