Proving the congruence $((p-1)\ /\ 2)!^2 \equiv (p-1)\ (\textrm{mod}\ p)$ $$\left(\frac{p-1}{2}\right)!^2 \equiv (-1)\ (\textrm{mod}\ p)$$ Given $p$ is a prime congruent to $1$ modulo $4$.
I know there's a way to do this with Wilson's theorem but wondering if my proof is right.
We know since $p \equiv 1\ mod\ 4$, $p$ is of the form $4n + 1$
We can rewrite $x = \frac{p-1}{2}!$ as $\frac{p-1}{2} \cdot \frac{p-1}{2} - 1 \cdot \frac{p-1}{2} -2\ \cdot\ ...\ \cdot1 = \frac{p-1}{2} \cdot \frac{p-3}{2} \cdot \frac{p-5}{2}\ \cdot\ ...\ \cdot1 = \frac{4n+1-1}{2} \cdot \frac{4n+1-3}{2} \cdot \frac{4n+1-5}{2}\ \cdot\ ...\ \cdot1 = \frac{4n}{2} \cdot \frac{4n-2}{2} \cdot \frac{4n-4}{2}\ \cdot\ ...\ \cdot 1 = 2n\cdot (2n-1) \cdot (2n -2)\ \cdot\ ...\ \cdot1$
Now taking $x^2 =  4n^2((2n-1) \cdot (2n -2)\ \cdot\ ...\ \cdot1)^2$
Let $m = n^2((2n-1) \cdot (2n -2)\ \cdot\ ...\ \cdot1)^2$
We can write $x^2$ as $4m$.
$-1\ mod\ p $ is of the form $4n$ because we have $p$ of the form $4n + 1$ and $p - 1$ is then of the form $4n$.
So $x^2 \equiv -1\ mod\ p$

If $p \equiv 1 \bmod 4$, then $\left( \frac{p-1}{2} \right)^2 = 1 \times 2 \times \cdots \frac{p-1}{2} \times (-1) \times (-2) \times \cdots \times \left(-\frac{p-1}{2}\right)$, because the RHS has an even number of negative terms. The RHS covers every nonzero equivalence class modulo $p$, so we are left with $$(p-1)! \equiv -1 \pmod p$$ which is true because only $1$ and $-1$ are their own multiplicative inverses modulo $p$, so every other term in the product for $(p-1)!$ cancels.
