QuadraticCalc

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

Try an example

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).

    1. Enter a and the modulus n
    2. Reduce a mod n
    3. Test a^((n−1)/2) mod n for odd prime n
    4. Square every x from 0 to n − 1
    5. Collect the x values with x² ≡ a
    6. 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).

    x² ≡ a (mod n),  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?

    1. 6² = 36 = 2 × 13 + 10.
    2. 7² = 49 = 3 × 13 + 10.
    3. 10⁶ ≡ 1 (mod 13), so Euler’s criterion gives (10/13) = 1.
    4. 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.

    Quadratic Residue Calculator FAQ

    What Is a Quadratic Non-Residue?

    A quadratic non-residue is a number a with no x such that x² ≡ a (mod n). 3 is a non-residue mod 7.

    How Many Quadratic Residues Are There Modulo a Prime?

    An odd prime p has exactly (p − 1)/2 non-zero quadratic residues. 13 has 6: 1, 3, 4, 9, 10 and 12.

    What Is the Legendre Symbol?

    The Legendre symbol (a/p) equals 1 for a residue, −1 for a non-residue and 0 when p divides a, for an odd prime p.

    What Is Quadratic Reciprocity?

    Quadratic reciprocity links (p/q) and (q/p) for 2 odd primes: the 2 symbols are equal unless both primes leave a remainder of 3 when divided by 4.

    Where Are Quadratic Residues Used?

    Quadratic residues are used in the Rabin and Goldwasser–Micali cryptosystems, the quadratic sieve factoring algorithm and acoustic diffuser design.