# Wilson's Theorem Application to Quadratic Residues

Im a noob and trying to prove: $$(m!)^2\equiv(-1)^{m+1}\textrm{(mod p)}$$ using Wilson's Theorem. Although it's on Wikipedia, I want to really understand what is happening. Could someone explain how \begin{align*}1*2\dotsb*(p-1)=1*(p-1)*2*(p-2)\dotsb m*(p-m)\end{align*} What is m? How is it possible for (p-1)! to have this expansion. Then could someone also explain the property that was used to transform this: $$(-1)^m(m!)^2\equiv-1\textrm{(mod p)}$$ into $$(m!)^2\equiv(-1)^{m+1}\textrm{(mod p)}$$ I understand that $$-1^1*-1^m=-1^{m+1}$$, but how did the $$-1^m$$ move from the left side to the right. Thanks for help! Wilson's Theorem Quadratic Residue

$$m$$ is $$(p-1)/2$$.
You can multiply a congruence by the same thing on both sides. Also, $$(-1)^m\cdot(-1)^m=(-1)^{2m}=1$$. Thus the result.