[Math] Product of quadratic residues mod p $\equiv 1$ mod p iff $p \equiv 3$ mod 4

elementary-number-theory

Let $p$ be an odd prime number. Prove that the product of the quadratic residues modulo $p$ is congruent to $1$ modulo $p$ if and only if $p \equiv 3 \pmod 4$.

I've tried using the fact that any quadratic residue modulo $p$ must be one of the numbers $1,2,\ldots,p-1$. But then I got stuck. This problem should be solvable without any Legendre symbol trickiness.

Best Answer

Every quadratic residue is of the form $k^2$ for a $k \in \{1,\,\dotsc,\, \frac{p-1}{2}\}$. So the product of quadratic residues is

$$\prod_{k=1}^{\frac{p-1}{2}} k^2.$$

Now relate that to Wilson's theorem: Since $k^2 \equiv (-1)\cdot k \cdot (p-k) \pmod{p}$, we have

$$\prod_{k = 1}^{\frac{p-1}{2}}k^2 \equiv (-1)^{\frac{p-1}{2}}\prod_{k = 1}^{\frac{p-1}{2}} k \cdot \prod_{k = 1}^{\frac{p-1}{2}}(p-k) =(-1)^{\frac{p-1}{2}}\cdot (p-1)! \equiv (-1)^{\frac{p+1}{2}}\pmod{p}.$$

Thus the product of quadratic residues modulo $p$ is $\equiv 1 \pmod{p}$ if $p \equiv 3 \pmod{4}$ and it is $\equiv -1\pmod{p}$ if $p \equiv 1 \pmod{4}$.

Related Question