1.2.4. Wilson’s Theorem

This section is based on part of [BUR11, Sec. 5.3].

Lemma 1.2.4.1.

Let pp be a prime and a∈ℤ{a\in\mathbb{Z}}. The following statements are equivalent:

  1. (1)
    ​

    a2≡1(modp){a^{2}\equiv 1\pmod{p}}.

  2. (2)
    ​

    a≡1(modp){a\equiv 1\pmod{p}} or a≡−1(modp){a\equiv-1\pmod{p}}.

In particular, if 0<a<p{0<a<p}, then the above equivalent conditions hold if and only if a=1{a=1} or a=p−1{a=p-1}.

Proof.

(1)⇒{\Rightarrow}(2) Since a2−1=(a+1)⁢(a−1){a^{2}-1=(a+1)(a-1)} and pp is prime, using Euclid’s Lemma (Theorem 1.1.4.2), we conclude that p∣(a2−1){p\mid(a^{2}-1)} if and only if p∣(a+1){p\mid(a+1)} or p∣(a−1){p\mid(a-1)}, as required.

(2)⇒{\Rightarrow}(1) Immediate from Proposition 1.2.1.6(5).

The final claim is clear: for 0<a<p{0<a<p}, the congruence a≡1(modp){a\equiv 1\pmod{p}} implies a=1{a=1} and, since p−1≡−1(modp){p-1\equiv-1\pmod{p}}, the congruence a≡−1(modp){a\equiv-1\pmod{p}} implies a=p−1{a=p-1}. ∎

Theorem 1.2.4.2 (Wilson’s Theorem).

Let pp be a prime. Then

(p−1)!≡−1(modp).(p-1)!\equiv-1\pmod{p}.
Proof.

If p=2{p=2}, then (p−1)!=1{(p-1)!=1} and 1≡−1(mod2){1\equiv-1\pmod{2}} holds. If p=3{p=3}, then (p−1)!=2{(p-1)!=2} and 2≡−1(mod3){2\equiv-1\pmod{3}} holds. Let p>3{p>3} be prime. Consider the set

{2,3,…,p−2},\{2,3,\dots,p-2\},

which has p−3{p-3} elements. Corollary 1.2.2.7 and Lemma 1.2.4.1 imply that the above set is partitioned into (p−3)/2{(p-3)/2} pairs {a,b}\{a,b\} such that a≠b{a\neq b} and a⁢b≡1(modp){ab\equiv 1\pmod{p}}. Indeed, Corollary 1.2.2.7 implies that for each 0<a<p{0<a<p} there exists a unique 0<b<p{0<b<p} such that a⁢b≡1(modp){ab\equiv 1\pmod{p}}; Lemma 1.2.4.1 then shows that a=b{a=b} if and only if a=1{a=1} or a=p−1{a=p-1}. Using Proposition 1.2.1.6(5), we multiply these (p−3)/2{(p-3)/2} congruences to obtain

2⋅3⁢⋯⁢(p−2)≡1(modp).2\cdot 3\cdots(p-2)\equiv 1\pmod{p}.

By Proposition 1.2.1.6(4), we may multiply this congruence by p−1{p-1} to obtain

(p−1)!≡p−1(modp).(p-1)!\equiv p-1\pmod{p}.

Since p−1≡−1(modp){p-1\equiv-1\pmod{p}}, Proposition 1.2.1.6(3) yields the congruence

(p−1)!≡−1(modp).∎(p-1)!\equiv-1\pmod{p}.\qed
Remark 1.2.4.3.

The converse statement in Wilson’s Theorem (Theorem 1.2.4.2) also holds: if n>1{n>1} is an integer such that (n−1)!≡−1(modn){(n-1)!\equiv-1\pmod{n}}, then nn is a prime. Let 1≤d<n{1\leq d<n} be a divisor of nn. Then the congruence

(n−1)!≡−1(modd){(n-1)!\equiv-1\pmod{d}}

also holds. Moreover, dd divides (n−1)!(n-1)! since 1≤d<n{1\leq d<n}. Therefore,

0≡−1(modd),0\equiv-1\pmod{d},

which is possible if and only if d=1{d=1}. This shows that nn is prime.