I am studying group theory so I do it by using the concept of group.

What I am trying to prove is if p is prime then $(p-1)!\equiv-1\mod p$

Note that $\mathbb{Z_p}$ forms a multiplicative group. Hence $\forall a \in \{1,2,\dots,p-1\},\exists a^{-1}\in \{1,2,\dots,p-1\}$

This means that $aa^{-1}\equiv 1\mod p$

If $a=a^{-1}, 1 \equiv aa^{-1}= a^2 \mod p$, So this means that $a \equiv \pm 1 \mod p$. (I am not sure that why this is true, is it because the group is abelian?)

"We have seen that this necessitates $a ≡ ±1 (\mod p)$ and so a = 1 or a = p − 1." ( I totally can't understand this sentence.)

Then we pair up $(p-1)!=1(2)\dots(p-2)(p-1)$ such that every element is with their multiplicative inverse.

So all the other pairs get $-1$ except for the pair ((1)(p-1)). Why this will happens?

I am not familiar with number theory so I hope I can get some idea or explaination about those statements.

  • 1
    $\begingroup$ @Pierre-GuyPlamondon: In fact only half of it, since the question is only about one direction of the "if and only if" in Wilson's theorem. $\endgroup$
    – joriki
    Jul 21, 2015 at 7:39
  • $\begingroup$ The fact that the only idempotent (i.e. self-inverse) elements in $\Bbb{Z}_p^*$ are $\pm 1$ is due to the fact that $\Bbb{Z}_p^*$ has exactly one subgroup of order $2$. It isn't related to commutativity. $\endgroup$
    – A.P.
    Jul 21, 2015 at 7:46
  • 2
    $\begingroup$ As @dREaM noted, you've got the wrong pairing -- you're pairing the numbers with their additive inverses, but you should be pairing them with their multiplicative inverses. $\endgroup$
    – joriki
    Jul 21, 2015 at 7:47
  • $\begingroup$ I deleted the comment @joriki was mentioning. It said $2(p-2)$ is congruent to $-4\bmod p$ which is not always $-1\bmod p$. $\endgroup$
    – Asinomás
    Jul 21, 2015 at 7:49
  • $\begingroup$ see wiki en.wikipedia.org/wiki/Wilson%27s_theorem for a proof of Wilson's theorem using sylow theorem... $\endgroup$
    – Ripan Saha
    Jul 21, 2015 at 7:52

2 Answers 2


Your first question: If $a^2=1$ then $a^2-1=(a-1)(a+1)=0$. Since $\mathbb{Z}/(p)$ is a field, this implies that either $a-1=0$ or $a+1=0$ or that $a=\pm 1$.

For the next one. The only numbers between $0$ and $p-1$, that satisfy $a=\pm 1$ are $1$ and $p-1$, this is clear since $a=-1=p-1$ mod $p$.

Lastly, if we think of $(p-1)!$, this is the product of all the elements of the multiplicative group together. Group theoretically, consider $\prod_{g\in G} g$. Then, for each $g$, we can find the $g^{-1}\in G$ in the product and cancel. This aurgument only breaks down if $g^{-1}=g$, so in the product we are left with $\prod_{g\in G, g^2=1}g$. In the case of $G=\mathbb{Z}/(p)^*$, we have just shown that the only such elements at $p-1$ and $1$, so that $(p-1)!=\prod_{g\in \mathbb{Z}/(p)^*}g=\prod_{g\in \mathbb{Z}/(p)^*, g^2=1}g=(p-1)1=-1$ mod $p$. This is probably what they mean by pairing.

  • $\begingroup$ @joriki Wow, I might be up a bit too late. Thanks for catching that! $\endgroup$
    – pax
    Jul 21, 2015 at 7:49

Let's do it for odd primes:

The multiplicative group of a finite field is cyclic. In this case the cyclic group is $\mathbb Z_{p-1}$.

We know a lot of things about groups, we know each element has a unique inverse, we know even more about cyclic groups, we know there are $\varphi(d)$ elements of order $d$ when $d$ divides the order of the group. Of course $2|(p-1)$ so we deduce there are $\varphi(2)=1$ elements of order $2$, in other words there are exactly two self inverses, $1$ and $-1$.

So when you take the product of all numbers what happens is that all of the pairs of inverses cancel out and you are only left with $1\cdot (-1)=-1$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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