Quadratic Residue Checker

x² ≡ a (mod n)?

CalculatorsFreeNo Signup
4.8(657 reviews)
All Tools

Loading tool...

About Quadratic Residue Checker

A quadratic residue checker determining if a ≡ x² (mod n) is solvable. Finds all square roots when they exist, lists all quadratic residues mod n, and computes the Legendre/Jacobi symbols. All calculations are client-side.

Quadratic Residue Checker Features

  • QR check
  • Square roots
  • QR list
  • NR list
  • Legendre symbol
Quadratic residue: a is a QR mod n if x² ≡ a (mod n) has a solution. For prime p: exactly (p−1)/2 non-zero QRs. Product of QRs is QR, product of NRs is QR, QR×NR is NR. Finding square roots: Tonelli-Shanks algorithm.

How to Use

Enter a and n:

  • QR?: Is a a quadratic residue mod n?
  • Roots: All x with x²≡a
  • List: All QRs mod n

Properties

  • QR × QR = QR
  • NR × NR = QR
  • QR × NR = NR
  • −1 is QR mod p iff p≡1 (mod 4)

Square Root Algorithms

For p≡3 (mod 4): x = a^((p+1)/4). General: Tonelli-Shanks algorithm. For composite n: combine solutions via CRT after factoring n.

Step-by-Step Instructions

  1. 1Enter a.
  2. 2Enter modulus n.
  3. 3Check QR.
  4. 4Find square roots.
  5. 5View QR list.

Quadratic Residue Checker — Frequently Asked Questions

How to find modular square roots?+

For prime p≡3 (mod 4): simply compute a^((p+1)/4) mod p. Otherwise use Tonelli-Shanks: factor p−1 = 2ˢ·q, find a non-residue z, then iteratively adjust using z's powers. For composite n: factor n, solve mod each prime power, combine via CRT.

When is −1 a quadratic residue?+

−1 is a QR mod p iff p≡1 (mod 4). This is because (−1)^((p−1)/2) = 1 iff (p−1)/2 is even, i.e., p≡1 (mod 4). For example: −1 is a QR mod 5 (2²≡4≡−1) but not mod 7.

How does this relate to Gaussian integers?+

A prime p splits in Z[i] as (a+bi)(a−bi) iff −1 is a QR mod p, i.e., p≡1 (mod 4). Primes p≡3 (mod 4) remain prime in Z[i]. This connects quadratic residues to algebraic number theory.

Share this tool: