Leibniz theorem : A natural number $p> 2$ is prime iff $(p - 2)!-1 \equiv 0 \pmod p$.

I thought of using Wilson's theorem for the proof.

First we have by Wilson's theorem $$(p - 1)!+1 \equiv 0 \pmod p$$ We can write this as $$(p - 2)!(p-1)+1 \equiv 0 \pmod p$$ $$(p - 2)!(p-1)+1=p(p-2)!-[(p-2)!-1]$$ Hence the right side p(p-2)! is divisible by p also the other term is divisible by p. So we have $$(p - 2)!-1 \equiv 0 \pmod p$$.

Is this correct?

• You know wilson's theorem? Use that. Dec 26 '15 at 18:04
• An equivalent statement is widely (and probably unreasonably) known as Wilson's Theorem. A search will yield many hits. Dec 26 '15 at 18:05
• Dec 26 '15 at 18:10
• The proof is trivial, you simply invoke that there is a primitive element x, so that the numbers you need to multiply will be given by the powers of x. You need to omit p-1, but that's -1 so, you multiply by -1. Dec 26 '15 at 18:13
• For the direction that the congruence fails when $p$ is composite, see this earlier Question. Dec 26 '15 at 18:35

The proof is very simple: first by Wilson theorem: $$(p-1)! \equiv -1 \pmod p$$ with $p$ prime, now we add $p$ to the right side: $$(p-1)(p-2)! \equiv (p-1) \pmod p$$ since $gcd(p-1,p)=1$ by cancellation law we can cancel $(p-1)$ on both sides $$(p-2)! \equiv 1 \pmod p$$ $$(p-2)!-1 \equiv 0 \pmod p$$