Euler's Criterion
Which nonzero remainders modulo a prime are perfect squares? How can we decide this quickly without listing all squares? This question — quadratic residuosity — sits at the heart of classical number theory. It reappears constantly in modern applications. Given a prime and an integer not divisible by , we want a fast test. We need to know whether has a solution. This should avoid brute-force searching over all from to . Euler's Criterion answers this with a single modular exponentiation. is a quadratic residue mod exactly when . This is remarkable. It converts a search problem (does some square to ?) into a computation problem (raise to a fixed power). The criterion is the engine behind the Legendre Symbol's multiplicativity. It also drives fast primality-adjacent tests. And it underlies the entire machinery of Quadratic Reciprocity that follows it. The big picture is this: Fermat's Little Theorem tells us for any coprime to . Euler's Criterion refines this. It shows that the "square root" of that statement, , already carries full information. This information tells us whether is a square modulo . It can only be or modulo , and it tells you which. This single fact is the bridge between two worlds. One is the purely group-theoretic structure of . The other is the classical, symbol-based language of quadratic residues. This article gives a complete, self-contained proof of Euler's Criterion. It builds from Fermat's Little Theorem and elementary properties of finite fields. It then uses the criterion to compute in closed form. This determines exactly which primes have as a quadratic residue. This is the first of the "supplementary laws." It is also a direct stepping stone toward Gauss's Lemma and the full law of Quadratic Reciprocity.
- Euler's Criterion states for odd prime and .
- It converts the question "is a square mod ?" into a single fast modular exponentiation.
- The proof rests on Fermat's Little Theorem and the fact that a polynomial of degree has at most roots mod a prime.
- As a corollary, iff , and iff .
- The criterion also gives a clean, computational proof that the Legendre symbol is completely multiplicative in its top argument.
- It is the direct ancestor of Gauss's Lemma and the launching point for Quadratic Reciprocity.
- Key idea: the value is forced to be , and it is exactly when is a square.
Where this lives today
Euler's Criterion is the computational backbone of the Tonelli–Shanks algorithm for computing square roots modulo a prime, which is used throughout elliptic-curve cryptography to decompress compressed point representations. In cryptographic protocol design, testing quadratic residuosity via fast exponentiation (rather than brute-force search) is essential when primes have hundreds of digits, since it runs in polynomial time via repeated squaring while brute force is exponential. The criterion also underlies the Solovay–Strassen primality test, a randomized algorithm predating the more common Miller–Rabin test, which checks whether agrees with the Jacobi symbol to probabilistically detect compositeness. In pure mathematics, it is the direct stepping stone to Gauss's Lemma and the full Quadratic Reciprocity law, and its generalization to -th power residues (via in cyclic groups ) appears in the study of cyclotomic fields and Gauss and Jacobi sums. In coding theory and combinatorial design, quadratic residues mod (whose recognition relies on this criterion) are used to build Paley graphs and quadratic-residue difference sets.
Ask the tutor: How does Euler's Criterion combine with Gauss's Lemma to prove the full law of Quadratic Reciprocity?
Let be an odd prime and let be an integer with . We say is a quadratic residue modulo if the congruence
has a solution ; otherwise is a quadratic nonresidue. The Legendre symbol is defined by
When , the symbol is often extended by declaring it depends only on , since is solvable iff is solvable for any .
Intuition
Think of the nonzero residues modulo as forming a group under multiplication, , which has order . Squaring is a group homomorphism from this group to itself, . Its image is exactly the set of quadratic residues. Because squaring is "2-to-1" (each nonzero square has exactly two square roots, and , which are distinct since is odd), the image — the quadratic residues — has size exactly . So half the nonzero residues are squares and half are not. Euler's Criterion gives an algebraic litmus test distinguishing the two halves. Raise to the power : Fermat's Little Theorem guarantees , so is a square root of modulo , forcing it to be . The claim is that it lands on precisely for the residues, and precisely for the nonresidues. Picture the nonzero residues mod split into two equal camps by the exponentiation map ; the criterion says this split coincides exactly with the residue/nonresidue split.
The central theorem
Let be an odd prime and let with . Then
That is, if is a quadratic residue mod , and if is a quadratic nonresidue mod .
Let be prime and let be a polynomial with integer coefficients such that (so has degree exactly modulo ). Then the congruence has at most incongruent solutions modulo .
We argue by strong induction on , using polynomial division modulo a prime, i.e. working in the field where every nonzero element is invertible. Base case . Then with , so never holds; there are solutions. Inductive step. Suppose the lemma holds for all degrees less than , and let have degree with . If has no solutions, then trivially it has at most solutions and we are done. Otherwise let be a solution: . Perform polynomial division with remainder over the rationals (or directly with integer coefficients, since we divide by the monic-after-scaling factor ): there exist integers-coefficients polynomial of degree and a constant such that
identically as polynomials. Substituting gives , so , hence
as a congruence of polynomials (i.e. all coefficients agree mod ), where has leading coefficient equal to (division by the monic linear factor does not change the leading coefficient), so (leading coefficient of ) and has degree exactly modulo . Now suppose is any solution of with . Then
Since is prime, has no zero divisors: if then or . We assumed , i.e. , so we must have , i.e. . Thus every solution of other than (mod ) is a solution of . By the inductive hypothesis, has at most incongruent roots mod . Adding back itself, has at most incongruent roots mod . This completes the induction.
∎Proof of Euler's Criterion. We use Fermat's Little Theorem, the root-counting lemma just proved, and basic group theory of .
Step 1: . By Fermat's Little Theorem, since ,
Write , an integer since is odd. Then
Since is prime, has no zero divisors, so or ; that is,
and (since is odd, ) exactly one of these holds for each .
Step 2: If is a quadratic residue, then . Suppose for some with (note forces ). Then by Fermat's Little Theorem applied to ,
Step 3: Exactly of the residues are quadratic residues. Consider the squaring map , . Its image is precisely the set of quadratic residues (nonzero, since ). For ,
Since and is odd, and cannot both hold unless and , impossible for odd unless... more directly: for fixed , the two solutions and of are distinct because (as is odd, for integer ). Hence is exactly 2-to-1 onto its image, so
Step 4: The count of solutions to is at most . By the root-counting Lemma applied to , which has degree and leading coefficient (so ), the congruence
has at most solutions among .
Step 5: Conclusion by counting. By Step 2, every quadratic residue satisfies ; by Step 3 there are exactly quadratic residues. So the congruence has at least solutions (namely, all the quadratic residues, which are distinct mod ). By Step 4 it has at most solutions. Hence it has exactly solutions, and these must be precisely the quadratic residues — no nonresidue can also satisfy , since that would give more than solutions, contradicting Step 4. Therefore for a quadratic residue , , and for a quadratic nonresidue , by Step 1 (exactly one of occurs) and the exclusion just proved, . In both cases , as claimed.
∎For odd prime and integers with ,
By Euler's Criterion,
Both sides of (as an equation, not just a congruence) lie in , and two elements of that are congruent mod (for , so ) must be equal, since . Hence the congruence upgrades to an honest equality.
∎For every odd prime ,
Equivalently, .
Apply Euler's Criterion with (valid since for any prime ):
The right side is exactly (an honest integer, not just a residue class), and the left side is also exactly . Since is odd, , so two values in congruent mod must be equal:
Now determine the parity of from . Write or (these are the only options for an odd prime). If , then , which is even, so . If , then , which is odd, so . This exactly matches the two cases and , completing the proof.
∎Worked examples
Example 1: Deciding quadratic residuosity via direct exponentiation, , . We test whether has a solution, using Euler's Criterion with exponent . Compute by repeated squaring.
Now , so
Compute . Then . So , and by Euler's Criterion : 15 is a quadratic nonresidue mod 23. As a sanity check by brute force, the quadratic residues mod 23 are the squares of : , giving the set — indeed is absent, confirming the computation.
Example 2: Using multiplicativity plus to shortcut a computation, , . We want . First, , so , and by the corollary . By multiplicativity (Corollary above),
We compute directly via Euler's Criterion, exponent . Repeated squaring mod :
Since ,
Compute stepwise: . Then . Then . So , giving . Therefore
so is a quadratic nonresidue mod . (Check of the sub-claim: is a QR mod because , confirming independently.)
Euler's Criterion is false, and the underlying root-counting lemma fails, if is replaced by a composite modulus. Take (not prime) and , with exponent not even an integer — already the statement doesn't parse — so instead compare against the more informative failure at , testing , a genuine square mod (), with the "expected" exponent (using the same formula naively). Compute . Since , we get , which is not at all. The clean dichotomy "" simply breaks: is not cyclic (it's ), Fermat's Little Theorem itself fails for composite moduli in this form, and the root-counting lemma (a polynomial of degree has at most roots) also fails: the congruence has four solutions, , exceeding the degree . This is precisely because has zero divisors ( despite neither factor being ), so the key step " or " used in both the lemma and the main proof is simply unavailable. Primality of the modulus is not a decorative hypothesis — it is exactly what makes the zero-divisor-free argument, and hence the entire proof, go through.
Scope, edge cases & common traps
| Situation | What happens | Why |
|---|---|---|
| Euler's Criterion as stated does not apply | is not well-defined as an exponent giving distinctness; every unit mod is , the theory is degenerate | |
| Legendre symbol is defined to be , and too | Consistent extension, but this case is excluded from the theorem's hypotheses and should be checked separately | |
| Composite modulus | Criterion generally false | need not be cyclic and has zero divisors in ; see counterexample above |
| Computing by hand for large | Never expand literally | Use repeated squaring (fast exponentiation); this is what makes the criterion computationally useful |
| Congruence vs. equality | is a congruence | It upgrades to true equality only because both sides lie in and separates from |
The mathematician behind it
Origins · 1 minLeonhard Euler and how this was discovered
Euler was the most prolific mathematician of the eighteenth century, contributing foundational work across analysis, mechanics, graph theory, and number theory. In number theory he studied quadratic and higher residues extensively, proved special cases of what would become quadratic reciprocity, and developed criteria — including the one bearing his name here — for testing residuosity using exponentiation, well before the group-theoretic language of finite fields existed to streamline the proof. His empirical and computational approach to conjectures in this area anticipated the general reciprocity law that Gauss would later prove completely.
Does Euler's Criterion tell you the actual square root , not just whether one exists?
No — it only decides existence, not the value. Euler's Criterion computes and checks whether this equals or ; it never touches an explicit with . Finding explicitly is a separate, harder computational problem, solved for example by the Tonelli–Shanks algorithm (which in fact uses Euler's Criterion as a subroutine to guide its search). For primes , there is a simple closed form once you already know is a residue, but this shortcut does not generalize to all primes, which is why a full square-root algorithm is more delicate than the residuosity test itself.
Can Euler's Criterion be extended to prime powers or composite moduli?
Not directly in the same clean form, though analogues exist. The proof relies crucially on being a field, so that Fermat's Little Theorem holds and polynomials have boundedly many roots. For prime powers one can use Hensel lifting to relate residuosity mod back to residuosity mod , but this requires separate lifting arguments, not a direct analogue of the criterion itself. For general composite , one instead works with the Jacobi symbol, a formal extension of the Legendre symbol satisfying reciprocity-like formulas, but the Jacobi symbol being no longer implies is actually a quadratic residue mod — this asymmetry is exactly what the Solovay–Strassen primality test exploits.
How is Euler's Criterion related to Gauss's Lemma?
Gauss's Lemma is an independent, more geometric criterion for the Legendre symbol, counting how many of the least positive residues of modulo exceed ; the parity of that count gives . Historically and pedagogically, Gauss's Lemma is often proved independently of Euler's Criterion and then used, together with a clever lattice-point counting argument, to prove full Quadratic Reciprocity. Euler's Criterion and Gauss's Lemma both compute the same object, the Legendre symbol, but via different combinatorial routes — one via a single exponentiation, the other via a sign-counting argument on a set of representative residues.
Why can't be, say, modulo ?
Because is forced by Fermat's Little Theorem to be a square root of modulo : squaring it gives . In the field , the equation has at most two roots (by the root-counting lemma with ), and and are visibly both roots and distinct since is odd; so these are the only two roots, and must be one of them. No other residue class, like , can satisfy unless happens to divide , i.e. only in the special tiny case would coincide with the allowed value — consistent, not a counterexample.
Is the converse of Euler's Criterion also true — if , is necessarily a quadratic residue?
Yes, and this converse is exactly the content proved in Step 5 of the proof above, via the counting argument: since there are exactly quadratic residues and the polynomial has at most roots, the residues account for all the roots, leaving no room for any nonresidue to also satisfy the congruence. So the two directions "residue " and " residue" are logically intertwined in this proof, both established simultaneously by the counting argument rather than proved as separate implications.
What role does the assumption play?
It ensures is a unit modulo , so that is a well-defined nonzero element to which Fermat's Little Theorem applies. If , then , and as well, which trivially matches the convention , but this case sits outside the "residue vs. nonresidue" dichotomy the theorem is built to distinguish and is handled by definition rather than by the proof's counting argument.