I need to prove that if p is an odd prime and
$r = (p-1)/2$ then
$(r!)^2 ≡ (−1)^{r−1} \pmod p$
I think it has something to do with gauss's lemma
https://en.wikipedia.org/wiki/Gauss%27s_lemma_(number_theory)
but I tried a lot and couldn't find a way to break it .
any help or hint will be appreciated.
Hint: We have $p-1\equiv -1\pmod{p}$, $p-2\equiv -2\pmod{p}$, $p-3\equiv -3\pmod{p}$, and so on up to $\frac{p+1}{2}\equiv -\frac{p-1}{2}\pmod{p}$.
It follows that $$(p-1)!\equiv (-1)^{(p-1)/2}\left(\left(\frac{p-1}{2}\right)!\right)^2\pmod{p}.$$ Now use Wilson's Theorem.