# If $p$ is a prime, then $(p-1)! \equiv -1 (mod p)$ [duplicate]

If $$p$$ is a prime, then $$(p-1)! \equiv -1 (mod p)$$. Hint: $$(p-1)!$$ is the product of elements in $$Z_p$$. Match each element to its inverse.

I can understand by testing some primes that for any prime $$(p-1)!+1$$ is a multiple of that prime, but I'm not sure how to prove it in general or how inverses play into it.

• What about the hint given to you? "How do inverses play into it" well, inverses cancel each other out, so you need to locate the inverses in the product $(p-1)!$, and see what cancels out, and what does not. Some elements in that product have an inverse in that product. Some, do not. Oct 2 '20 at 3:29
• Look up Wilson's Theorem either via google or in any intro number theory book. [that's the displayed statement] Oct 2 '20 at 3:29
• There are only even number amount of elements in the group, and $a=a^{-1}$ iff $a=\pm1$. Oct 2 '20 at 3:31
• It is Wilson's Theorem and the converse is also true
– user824627
Oct 2 '20 at 3:31
• i made it too complicated for myself. thank you everyone
– d.v.
Oct 2 '20 at 3:50