# If $p \equiv 1 \pmod{4}$, prove $((\frac{p-1}{2})!)^2 \equiv -1 \pmod {p}$ where p is prime.

Characteristics: The fields where $p \equiv 1 \pmod{4}$ has half the number from 1 to $\frac{p-1}{2}$ both in positive and the negative. There can be paired up such that when multiplied together, they equal $-(p-1) \equiv +1 \pmod p$. Only one pair equals -1 and that is $\pm 1$.

Why does that happen?

-

If we start from Wilson's theorem, $(p-1)! \equiv -1 \pmod{p}$ for a prime $p$, then we can write

\begin{align} -1 &\equiv (p-1)! = \prod_{k=1}^{\frac{p-1}{2}} k \cdot \prod_{m = 1}^{\frac{p-1}{2}} (p-m)\\ &\equiv \left(\frac{p-1}{2}\right)! \cdot (-1)^{\frac{p-1}{2}}\prod_{m = 1}^{\frac{p-1}{2}} (m-p)\\ &\equiv (-1)^{\frac{p-1}{2}} \left(\left(\frac{p-1}{2}\right)!\right)^2 \end{align}

for odd primes $p$. Now if $p \equiv 1 \pmod{4}$, the factor $(-1)^{\frac{p-1}{2}}$ is $1$, hence

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

then.

It is Wilson's theorem that follows from pairing up each $1 < k < p-1$ with its inverse, leaving $(p-1)! \equiv 1\cdot(p-1) \equiv -1 \pmod{p}$.

-