Inputs
Any integer.
Odd prime greater than 2.
The modulus is checked with the site's primality classifier: below 3.3 × 10²⁴ the answer is exact, above it p is only a probable prime and the result is labeled as assuming p is prime. Computation runs locally in your browser.
Result
—
Solution steps
Method
For an odd prime p the Legendre symbol is
The value 1 means a nonzero quadratic residue: some integer x satisfies x² ≡ a (mod p). This calculator decides whether such an x exists; it does not compute it.
Euler's criterion. If p ∤ a, Fermat's theorem gives a^(p−1) ≡ 1 (mod p), and the half-power refines it:
So the half-power is 1 for a quadratic residue and −1 for a nonresidue. The calculator reduces a modulo p, handles p | a and a ≡ 1 directly, and otherwise computes a₀^((p−1)/2) mod p by modular exponentiation. For a prime p the residue is always 1 or p-1; any other residue proves that p is composite, and then no symbol value is given.
Exact or conditional. If p is below 3.3 × 10²⁴ it is proven prime and the answer is exact. Above that the site's classifier only establishes a probable prime, and the result is reported as assuming p is prime.
Supplementary laws.
Quadratic reciprocity. For distinct odd primes p and q:
Equivalently (p/q) = (q/p) unless both primes are congruent to 3 modulo 4, in which case the sign changes. It is not used by this calculator.
Group-theory view. The group of units (ℤ/pℤ)^× has order p-1. The nonzero squares form a subgroup of index 2, so they contain (p-1)/2 elements: exactly half of the nonzero residue classes are quadratic residues. If g is a primitive root modulo p, then (g/p) = −1, because g has order p-1 and cannot lie in a subgroup of order (p-1)/2.
Related: Primality Test · Modular Exponentiation · Primitive Roots · Multiplicative Order