# For which primes $p$ is $(p-6)! \equiv 1 \mod p$ defined?

For which primes $p$ is $(p-6)! \equiv 1 \mod p$ defined?

I brute forced it by repeatedly trying lots of primes and ended up with $p=7, p=17$. Does anyone have a better method to do this?

• Hint: $(p-1)! = -1 \mod p$ May 10, 2018 at 23:04
• Adding to what @VladislavKharlamov said, this is known as Wilson's Theorem. May 11, 2018 at 1:16

## 1 Answer

We rewrite our expression as: $$(p-1)!(p-5)^{-1}(p-4)^{-1} \ldots (p-1)^{-1} \equiv 1 \mod p$$ Using Wilson's theorem we get: $$-(p-5)^{-1}\ldots(p-1)^{-1} \equiv 1 \mod p$$
But $$(p-5)^{-1}(p-4)^{-1} \ldots (p-1)^{-1} \equiv (-5!)^{-1} \mod p$$ Then, need find $p$ : $$-(-5!)^{-1} \equiv 1 \mod p \Leftrightarrow 5! \equiv 1 \mod p$$
It is clear that if the simple is more than 120, then the remainder will not exactly be equal to 1, it remains to sort out the cases less, or try to come up with something else.

• In other words, $p$ must divide $5!-1 = 119$. Not too many of those... May 10, 2018 at 23:23
• I wanted the OP to take the last step myself :) May 10, 2018 at 23:25
• It might be worth rephrasing the start of this; it kind of looks right now that you're saying that Wilson's theorem at the first step, whereas you're just rewriting the equation we're examining so that you can use Wilson's theorem at the second step. May 11, 2018 at 0:06
• That's better? ... May 11, 2018 at 0:14