Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How might one show that $p$ divides $(p-2)!-1$ where $p$ is a prime number? I am not even sure if it is true but I have been randomly trying it on some primes and it seems to be true.

share|cite|improve this question
Does not compute. Only 1 and p dividies p for p prime. – Laylady Jan 25 '12 at 17:45
Do you know Wilson's Theorem? $(p-1)!\equiv -1\pmod{p}$. Hence $(p-2)!(p-1) \equiv (p-1)\pmod{p}$, and cancelling $p-1$ (which is relatively prime to $p$) we get $(p-2)!\equiv 1\pmod{p}$. – Arturo Magidin Jan 25 '12 at 17:46
Did you mean "$p$ divides $(p-2)!-1$"? – Michael Hardy Jan 25 '12 at 17:46
@all: [Laylady's comment] answers an earlier version of the question (which asked why $(p-2)!-1$ divides $p$). – Srivatsan Jan 25 '12 at 17:52
@MichaelHardy: of course you are right, careless me. :) – Yves Jan 25 '12 at 18:41

Indeed it is, this is a simple corollary of Wilson's theorem: If $p$ is prime, then $(p-1)! \equiv -1$ mod p (the converse is also true, but we don't need that).

So, assuming Wilson's theorem, $-1 \equiv (p-1)! \equiv (p-1)(p-2)!\equiv -(p-2)!$ from which we immediately get $(p-2)! \equiv 1$ mod p.

To prove Wilson's theorem, see here:

Edit: Whoops, I see I was beaten to this answer in the comment thread, sorry.

share|cite|improve this answer
Thank you, I don't know why the accept this answer button would't work... – Yves Jan 25 '12 at 18:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.