# Finishing of basic proof of Wilson's theorem

I've been trying to simplify my proof of Wilson's theorem so that I can easily understand it, but I'm running into some trouble. I reached the point where I proved $$(p-1)! \equiv -(p-2)! \mod p$$, but I'm wondering how I can push this further. I understand that each number in $$(p-2)!$$ has an inverse that will cancel it out to equal 1, but is there a way of proving that $$(p-2)! \equiv 1 \mod p$$ in a more elementary fashion? Thanks

• "each number in $(p−2)!$ has an inverse that will cancel it out to equal 1" is a great idea! Can you find out which numbers in $(p-2)!=1\times2\times...\times p-2$ are their own inverse? That is which values of $x$ such that $x^2=1$ in $\mathbb{Z}_p$? Once you you have found this numbers, the others cancel out as you have noticed.
– Gio
Jan 18 at 14:48
• Sorry, I'm just a bit confused by the wording. I thought the only inverses which are themselves are 1 and $p-1$? I cancelled these out already, but is there any other way I can prove that $(p-2)!$ is congruent to 1 mod p? I feel like the fact that inverses cancel each other out doesn't really stick with me yet, as the modulus operation was only introduced to us this year. Jan 18 at 15:00

Alternative proof :

If you want another way of thinking about Wilson's theorem, here is an expeditive proof :

1. Check that in $$\mathbb{Z}/p\mathbb{Z}[X]$$, $$X^p-X = \prod_{x \in \mathbb{Z}/p\mathbb{Z}} X-x$$ (these two polynomials are unitary, share the same degree and the same roots in the field $$\mathbb{Z}/p\mathbb{Z}$$)

2. Compare the coefficients of $$X$$.

Outline to prove that $$(p-2)! \equiv 1 \pmod p$$ (thanks to above comment from Gio and this thread):

1. For prime $$p$$, every positive integer $$a \in Z_p$$ has a unique "multiplicative inverse" $$x \in Z_p$$, that is, $$ax \equiv 1 \pmod p$$.

So for each integer $$a$$ in 1 to $$(p-2)$$, which has its multiplicative-inverse $$b$$ different from itself, you can combine $$a$$ and $$b$$ and we will have $$(ab) \bmod p = 1$$.

1. Now we are left with integers $$a$$ which are their own multiplicative-inverse. That is: $$a^2 \equiv 1 \pmod p$$. But that means, $$p | (a-1)(a+1)$$. Since $$p$$ is prime, this is only possible for $$a=1$$ and $$a=p-1$$. So, among 1 to $$(p-2)$$, there is only one such $$a=1$$.

(For Wilson's Theorem, we can directly use above arguments to say that: $$(p-1)! \bmod p = (p-1) \bmod p = (p-1)$$.)