Let $p$ be a prime, and let $a$ be any integer not divisible by $p$. Then we can define the Legendre symbol $\left(\frac{a}{p}\right)=\begin{cases} 1 & a\mathrm{\ is\ a\ quadratic\ residue\ modulo\ } p, \\ -1 & \mathrm{otherwise}.\end{cases}$

We say that $a$ is a quadratic residue modulo $p$ if there exists an integer $n$ so that $n^2\equiv a\pmod p$. We can then define $\left(\frac{a}{p}\right)=0$ if $a$ is divisible by $p$.

There are three parts. Let $p$ and $q$ be distinct odd primes. Then the following hold:

• $\left(\frac{-1}{p}\right)=(-1)^{(p-1)/4}$.
• $\left(\frac{2}{p}\right)=(-1)^{(p^2-1)/8}$.
• $\left(\frac{p}{q}\right)\left(\frac{q}{p}\right)=(-1)^{(p-1)/4\ (q-1)/4}$.

This theorem can help us evaluate Legendre symbols, since the following laws also apply:

• If $a\equiv b\pmod{p}$, then $\left(\frac{a}{p}\right)=\left(\frac{b}{p}\right)$.
• $\left(\frac{ab}{p}\right)=\left(\frac{a}{p}\right)\left(\frac{b}{p}\right)$.

There also exist quadratic reciprocity laws in other rings of integers. (I'll put that here later if I remember.)