Skip to content

Squares Modulo $n$

A quadratic congruence is a congruence involving a square. The basic form is

Quadratic Congruences

A quadratic congruence is a congruence involving a square. The basic form is

x2a(modn), x^2\equiv a\pmod n,

where a,nZa,n\in\mathbb{Z} and n>1n>1.

x2a(modn) x^2\equiv a\pmod n

The problem is to determine whether there exists an integer xx satisfying the congruence. If such an xx exists, then aa is called a quadratic residue modulo nn. Otherwise, aa is called a quadratic nonresidue modulo nn.

Quadratic congruences form the foundation of the theory of quadratic residues, one of the central subjects of classical number theory.

First Examples

Consider arithmetic modulo 77. Computing the squares gives

020, 0^2\equiv0, 121, 1^2\equiv1, 224, 2^2\equiv4, 3292, 3^2\equiv9\equiv2, 42162, 4^2\equiv16\equiv2, 52254, 5^2\equiv25\equiv4, 62361(mod7). 6^2\equiv36\equiv1\pmod7.

Thus the quadratic residues modulo 77 are

0,1,2,4. 0,1,2,4.

The quadratic nonresidues are

3,5,6. 3,5,6.

Hence the congruence

x22(mod7) x^2\equiv2\pmod7

has solutions, while

x23(mod7) x^2\equiv3\pmod7

does not.

Symmetry of Squares

Modulo a prime pp, the numbers xx and x-x always produce the same square:

x2(x)2(modp). x^2\equiv(-x)^2\pmod p.

Thus nonzero quadratic residues typically occur in pairs.

For example, modulo 1111,

22924(mod11). 2^2\equiv9^2\equiv4\pmod{11}.

This symmetry explains why there are only about half as many nonzero quadratic residues as nonzero residue classes.

Number of Quadratic Residues

Let pp be an odd prime. Among the nonzero residue classes modulo pp, exactly half are quadratic residues.

Indeed, the nonzero residues are

1,2,,p1. 1,2,\dots,p-1.

Since

x2(x)2(modp), x^2\equiv(-x)^2\pmod p,

the values

12,22,,(p12)2 1^2,2^2,\dots,\left(\frac{p-1}{2}\right)^2

produce all distinct nonzero quadratic residues.

Therefore there are exactly

p12 \frac{p-1}{2}

nonzero quadratic residues modulo pp.

Solving Quadratic Congruences

To solve

x2a(modn), x^2\equiv a\pmod n,

one may test residue classes directly when nn is small.

For example, solve

x24(mod9). x^2\equiv4\pmod9.

Checking squares modulo 99:

020, 0^2\equiv0, 121, 1^2\equiv1, 224, 2^2\equiv4, 320, 3^2\equiv0, 427, 4^2\equiv7, 527, 5^2\equiv7, 620, 6^2\equiv0, 724, 7^2\equiv4, 821. 8^2\equiv1.

Thus the solutions are

x2,7(mod9). x\equiv2,7\pmod9.

For large moduli, more sophisticated methods are required.

Squares Modulo Powers of Primes

Quadratic congruences modulo powers of primes are subtler.

For example,

x21(mod8) x^2\equiv1\pmod8

has four solutions:

x1,3,5,7(mod8). x\equiv1,3,5,7\pmod8.

Indeed, every odd square is congruent to 1(mod8)1\pmod8.

This differs from the prime modulus case, where quadratic congruences generally have at most two solutions.

Such phenomena motivate deeper investigations into congruences modulo composite numbers.

Polynomial Perspective

The congruence

x2a(modp) x^2\equiv a\pmod p

may be viewed as the polynomial equation

x2a=0 x^2-a=0

over the finite field

Fp. \mathbb{F}_p.

This viewpoint connects quadratic residues with algebraic structures over finite fields.

For example, if aa is a quadratic residue modulo pp, then the polynomial

x2a x^2-a

factors over Fp\mathbb{F}_p. Otherwise it remains irreducible.

Thus quadratic congruences link arithmetic with algebra.

Geometric Interpretation

The congruence

x2+y21(modp) x^2+y^2\equiv1\pmod p

defines a discrete analogue of the unit circle over the finite field Fp\mathbb{F}_p.

Studying such equations leads naturally to arithmetic geometry over finite fields, a subject central to modern algebraic number theory and cryptography.

Historical Context

The systematic study of quadratic residues began with entity[“people”,“Leonhard Euler”,“Swiss mathematician”] and reached a major milestone in the work of entity[“people”,“Carl Friedrich Gauss”,“German mathematician”].

Gauss regarded quadratic reciprocity as the “fundamental theorem” of arithmetic modulo primes. His investigations transformed congruence theory into a coherent mathematical discipline and laid the foundations for modern algebraic number theory.