However, Fact 16.4.4 is a terrible way to actually find quadratic residues for a given \(p\), since it involves finding a primitive root and listing lots of powers! We need both theory and practice.
Here is a much easier way. Recall our observation in Theorem 12.3.1: \begin{equation*}a^{(p-1)/2}\equiv\pm 1\text{ for all }a\text{ not divisible by }p\; .\end{equation*} We visualized it as the middle column in this graphic.
But as so often in mathematics, solving one question leads to another; after all, we didn't say when we got plus or minus 1, just that these are the only possibilities. Let's extend this as follows.
Theorem16.5.1Euler's Criterion
If \(p\) is an odd prime, then for all integers \(a\) not a multiple of \(p\), the sign of the following expression determines whether \(a\) is a QR. \begin{equation*}a^{(p-1)/2}\equiv\pm 1\text{ (mod }p)\end{equation*} We obtain \(+1\) if \(a\) is a QR, otherwise \(-1\).
Proof
Let \(g\) be a primitive root of \(p\), so that \(a\equiv g^i\) for some \(i\). Then if we let \(h=g^{(p-1)/2}\), Fermat's Little Theorem shows that \begin{equation*}h^2=g^{p-1}\equiv 1\text{ (mod }p)\, .\end{equation*}
Since \(g\) is primitive, \(h\equiv 1\) is impossible, so \(h\equiv -1\). But then \begin{equation*}a^{(p-1)/2}\equiv \left(g^i\right)^{(p-1)/2}\equiv \left(g^{(p-1)/2}\right)^i\equiv h^i \equiv (-1)^i\, .\end{equation*}
This is \(+1\) when \(i\) is even and \(-1\) when \(i\) is odd. According to Fact 16.4.4, this is precisely when \(a\) is a quadratic residue and nonresidue, respectively.
Example16.5.2
This immediately gives the result in Fact 16.1.2 that \(-1\) has a square root modulo an odd prime \(p\) precisely when \(p\equiv 1\) (mod \(4\)), because \((-1)^{(p-1)/2}=+1\) precisely when \((p-1)/2\) is even, or \(p\equiv 1\) (mod \(4\)). That is much easier than our previous ad-hoc way of doing it!
Using this same idea, we can prove a very nice result about when a composite number is a QR.
Proposition16.5.3
If \(n=ab\) is a factorization (not necessarily nontrivial) of \(n\), then \(n\) is a QR of \(p\) precisely when either both \(a\) and \(b\) are QRs of \(p\) or both \(a\) and \(b\) are not QRs of \(p\).
Modulo \(p\), write \(a\equiv g^i\) and \(b\equiv g^j\) for some \(i,j\). Then \(n=ab\equiv g^{i+j}\), and \(i+j\) is even when \(i\) and \(j\) have the same parity. Because of Fact 16.4.4, this is exactly the same thing as the conclusion of the proposition.
Hence if one of \(a,b\) is and the other isn't, neither is \(n=ab\).
Example16.5.4
Now I can immediately decide that \(-2\equiv 21\) is not a QR (mod \(23\)). Why? First, \(-2\equiv 21\); then recall that \(-1\) is not a QR but 2 is, which we knew before. Likewise, I can immediately decide that \(-2\equiv 9\) is a QR (mod \(11\)) by the fact that neither \(-1\) nor \(2\) is a QR.