Do arithmetic on a $13$-hour clock, that is, take remainders on division by $13$. The squares of $1, 2, \ldots, 12$ leave the remainders

$$1,\ 4,\ 9,\ 3,\ 12,\ 10,\ 10,\ 12,\ 3,\ 9,\ 4,\ 1.$$

Only six remainders appear: $1, 3, 4, 9, 10, 12$. We say these numbers are quadratic residues modulo $13$, and the other six, $2, 5, 6, 7, 8, 11$, are not. For every odd prime $p$, exactly half of the numbers from $1$ to $p - 1$ are quadratic residues. But which half? Fermat and Euler made hundreds of checks and found strange regularities: whether or not $3$ is a square modulo $p$ seemed to depend only on the remainder of $p$ on division by $12$.

The symbol

In 1798, in the Essay on the Theory of Numbers, Legendre introduced a notation that made these rules visible. For an odd prime $p$ and an integer $a$ not divisible by $p$, he wrote

$$\left(\frac{a}{p}\right) = \begin{cases} +1 & \text{if } a \text{ is a square modulo } p, \\ -1 & \text{if it is not.} \end{cases}$$

This is the Legendre symbol. It comes with a quick way of computing it, which Euler already knew: by Fermat’s little theorem, $a^{p-1} \equiv 1$, so $a^{(p-1)/2} \equiv \pm 1 \pmod p$, and the sign is exactly the symbol,

$$\left(\frac{a}{p}\right) \equiv a^{(p-1)/2} \pmod p.$$

For example, $3^6 = 729 = 56 \cdot 13 + 1$, so $\left(\frac{3}{13}\right) = +1$, as the list above shows. From this formula it follows that the symbol is multiplicative: $\left(\frac{ab}{p}\right) = \left(\frac{a}{p}\right)\left(\frac{b}{p}\right)$.

Title page of the *Essay on the Theory of Numbers*, "by A. M. Le Gendre, of the National Institute", dated year VI of the Republic (1797–1798). The symbol (a/p) first appears in this book.
Title page of the Essay on the Theory of Numbers, “by A. M. Le Gendre, of the National Institute”, dated year VI of the Republic (1797–1798). The symbol (a/p) first appears in this book.Internet Archive, University of Toronto copy · Wikimedia Commons · public domain

The law

With the symbol, the law that Euler had glimpsed and Legendre stated in 1785 fits on one line. If $p$ and $q$ are distinct odd primes,

$$\left(\frac{p}{q}\right)\left(\frac{q}{p}\right) = (-1)^{\frac{p-1}{2}\cdot\frac{q-1}{2}}.$$

In words: $\left(\frac{p}{q}\right)$ and $\left(\frac{q}{p}\right)$ are equal, unless $p$ and $q$ both leave remainder $3$ on division by $4$, in which case they are opposite. Asking whether $p$ is a square on a $q$-hour clock and asking whether $q$ is a square on a $p$-hour clock are, almost always, the same question. This is the law of quadratic reciprocity.

The law turns a hard calculation into a sequence of reductions. Is $7$ a square modulo $11$? Both leave remainder $3$ on division by $4$, so

$$\left(\frac{7}{11}\right) = -\left(\frac{11}{7}\right) = -\left(\frac{4}{7}\right) = -1,$$

because $11$ leaves remainder $4$ on division by $7$, and $4 = 2^2$ is a square. Indeed, the squares modulo $11$ are $1, 3, 4, 5, 9$, and $7$ is not among them.

In the table, each cell compares two primes. The red cells, where the two symbols are opposite, form a perfect pattern:

The missing proof

Legendre tried to prove the law in 1785 and again in the Essay. Both attempts had a gap: in certain cases he needed an auxiliary prime with special properties, for instance a prime of a certain form $4n + 1$ for which a given number was not a residue, and he could not prove that such a prime existed. Part of what he assumed is a case of the theorem on primes in arithmetic progressions, which Dirichlet would only prove in 1837.

Meanwhile, in Brunswick, an eighteen-year-old who had not read Legendre rediscovered the law on his own and, on 8 April 1796, found the first complete proof. He was Carl Friedrich Gauss, who published it in the Disquisitiones arithmeticae of 1801, called it the “golden theorem” and remarked, in a tone Legendre did not forget, that the Frenchman’s proof was insufficient.

Legendre complained more than once about the young German’s lack of courtesy, and relations between the two would get even worse with the dispute over least squares. But it was also he who made Gauss’s ideas known in France, and the later editions of his book, renamed Theory of Numbers in 1830, came to include a complete proof. The symbol, at any rate, kept his name: mathematicians still write $\left(\frac{a}{p}\right)$ today.

Exercise: 5 modulo 19

Decide whether $5$ is a square modulo $19$ and, if it is, find the root.

Since $5$ leaves remainder $1$ on division by $4$, the law does not change the sign: $\left(\frac{5}{19}\right) = \left(\frac{19}{5}\right) = \left(\frac{4}{5}\right) = +1$. Looking for the root: $9^2 = 81 = 4 \cdot 19 + 5$. So $9^2 \equiv 5 \pmod{19}$, and also $10^2 \equiv 5$, since $10 = 19 - 9$.

Exercise: 10 modulo 13

Use multiplicativity and the supplementary rule $\left(\frac{2}{p}\right) = +1$ if and only if $p$ leaves remainder $1$ or $7$ on division by $8$, to decide whether $10$ is a square modulo $13$.

$\left(\frac{10}{13}\right) = \left(\frac{2}{13}\right)\left(\frac{5}{13}\right)$. Since $13$ leaves remainder $5$ on division by $8$, $\left(\frac{2}{13}\right) = -1$. By reciprocity, $\left(\frac{5}{13}\right) = \left(\frac{13}{5}\right) = \left(\frac{3}{5}\right) = -1$, because the only squares modulo $5$ are $1$ and $4$. The product is $(-1)(-1) = +1$: $10$ is a square. Indeed, $6^2 = 36 = 2 \cdot 13 + 10$, as the list at the start shows.

Sources: Adrien-Marie Legendre, “Recherches d’analyse indéterminée”, Histoire de l’Académie royale des sciences (1785), and Essai sur la théorie des nombres (1798) · Carl Friedrich Gauss, Disquisitiones arithmeticae (1801), art. 151 · Franz Lemmermeyer, Reciprocity Laws: From Euler to Eisenstein (2000).


All topics on Adrien-Marie Legendre · ← The Elements of Geometry · How many primes are there up to x →

Image credits.