Q:

If $p$ is prime and $p$ $\equiv$ $1$ (mod 4), then the congruence $x^2$ $\equiv$ $-1$ (mod $p$) has two incongruent solutions...

Question: If $p$ is prime and $p$ $\equiv$ $1$ (mod 4), then the congruence $x^2$ $\equiv$ $-1$ (mod $p$) has two incongruent solutions given by $x$ $\equiv$ $\pm$ $\frac{(p-1)}{2}$!(mod $p$).

I noticed that the congruence $x^2$ $\equiv$ $-1$ (mod $p$) fits the form of Wilson's theorem but can't figure out how to modify/change the congruency to fit Wilson's theorem. Sorry if this is a duplicate, I wasn't able to find any other question similar to this one but it could just be my incorrect usage of MathJax.

A:

You need to consider the product $$-\frac {p-1}2 \cdot -\frac {p-3}2\cdot \dots -2\cdot -1\cdot 1 \cdot 2 \dots \cdot \frac {p-1}2 \equiv (p-1)!\bmod p$$

