Math 2.0

Number theory Proof

Proof of Wilson's theorem by pairing inverses

Builds on Prime numberCongruence modulo nDivisibilityGreatest common divisorExistence of inverses modulo nModular multiplicative inverseDivision algorithmEuclid's lemmaCancellation in congruencesCongruence is compatible with multiplication

Proof

  1. Let pp be a prime number. If p=2p = 2, then (p−1)!=1(p - 1)! = 1, and 22 divides 1−(−1)=21 - (-1) = 2. So (p−1)!≡−1(modp)(p - 1)! \equiv -1 \pmod p. From now on let p≥3p \ge 3.
  2. Let R={1,2,…,p−1}R = \{ 1, 2, \dots, p - 1 \}. Each a∈Ra \in R satisfies p∤ap \nmid a, so the greatest common divisor gcd⁡(a,p)\gcd(a, p) is a positive divisor of pp other than pp. Thus gcd⁡(a,p)=1\gcd(a, p) = 1.
  3. Let a∈Ra \in R. By step 2 and the existence of inverses modulo n, aa has a modular multiplicative inverse xx, so ax≡1(modp)a x \equiv 1 \pmod p.
  4. By the division algorithm, x=qp+a′x = q p + a' with 0≤a′<p0 \le a' < p. Then aa′≡ax≡1(modp)a a' \equiv a x \equiv 1 \pmod p. Since a⋅0=0≢1(modp)a \cdot 0 = 0 \not\equiv 1 \pmod p, we get a′≠0a' \ne 0, so a′∈Ra' \in R.
  5. If b∈Rb \in R and ab≡1(modp)a b \equiv 1 \pmod p, then ab≡aa′(modp)a b \equiv a a' \pmod p. By cancellation with gcd⁡(a,p)=1\gcd(a, p) = 1, b≡a′(modp)b \equiv a' \pmod p. Both lie in RR, so b=a′b = a'.
  6. So each a∈Ra \in R has exactly one a′∈Ra' \in R with aa′≡1(modp)a a' \equiv 1 \pmod p. Since a′a≡1(modp)a' a \equiv 1 \pmod p, step 5 applied to a′a' gives (a′)′=a(a')' = a.
  7. Let a∈Ra \in R. Then a′=aa' = a if and only if a2≡1(modp)a^2 \equiv 1 \pmod p, that is, p∣(a−1)(a+1)p \mid (a - 1)(a + 1).
  8. By Euclid's lemma, this holds if and only if p∣a−1p \mid a - 1 or p∣a+1p \mid a + 1. Since 0≤a−1≤p−20 \le a - 1 \le p - 2 and 2≤a+1≤p2 \le a + 1 \le p, this means a=1a = 1 or a=p−1a = p - 1.
  9. Let T={2,3,…,p−2}T = \{ 2, 3, \dots, p - 2 \}, which is empty when p=3p = 3. Let a∈Ta \in T. If a′=1a' = 1, then a≡aa′≡1(modp)a \equiv a a' \equiv 1 \pmod p, so a=1a = 1. If a′=p−1a' = p - 1, then −a≡aa′≡1-a \equiv a a' \equiv 1, so a=p−1a = p - 1. Both contradict a∈Ta \in T.
  10. So a↦a′a \mapsto a' maps TT to TT. By steps 6 and 8, it is its own inverse and has no fixed point in TT.
  11. Hence TT splits into disjoint pairs {a,a′}\{ a, a' \} with a≠a′a \ne a'. Each pair has product aa′≡1(modp)a a' \equiv 1 \pmod p.
  12. By compatibility with multiplication, (p−2)!=1⋅∏a∈Ta≡1(modp)(p - 2)! = 1 \cdot \prod_{a \in T} a \equiv 1 \pmod p. This also holds when TT is empty.
  13. Then (p−1)!=(p−1)⋅(p−2)!≡(−1)⋅1=−1(modp)(p - 1)! = (p - 1) \cdot (p - 2)! \equiv (-1) \cdot 1 = -1 \pmod p, by compatibility with multiplication and p−1≡−1(modp)p - 1 \equiv -1 \pmod p.

Idea

Modulo a prime, every nonzero residue has a unique inverse. Only 11 and −1-1 are their own inverses, so all the other factors of (p−1)!(p - 1)! cancel in pairs. What remains is 1⋅(p−1)≡−11 \cdot (p - 1) \equiv -1.

Reading path

To understand this page from the ground up, read these 36 pages in order. The foundations come first. The path takes the proofs Proof of Bézout's identity, Proof of the generalized Euclid's lemma, Proof of the commutativity of addition by induction, Proof of Euclid's lemma, Proof of strong induction from ordinary induction, Proof that congruence is compatible with multiplication, Proof of the well-ordering principle from strong induction, Proof of the division algorithm, Proof of the existence of inverses modulo n, Proof of cancellation in congruences.

Show the path as a graph
Definition by recursion, concept, no evidence levelDefinition by recursi…conceptDivisibility, definition, no evidence levelDivisibilitydefinitionMathematical induction, concept, no evidence levelMathematical inductionconceptNatural numbers, object, no evidence levelNatural numbersobjectPeano axioms, concept, no evidence levelPeano axiomsconceptCongruence modulo n, definition, no evidence levelCongruence modulo ndefinitionGreatest common divisor, definition, no evidence levelGreatest common divis…definitionPrime number, definition, no evidence levelPrime numberdefinitionSuccessor function, definition, no evidence levelSuccessor functiondefinitionModular multiplicative inverse, definition, no evidence levelModular multiplicativ…definitionProof that congruence is compatible with multiplication, proof, no evidence levelProof that congruence…proofCoprime integers, definition, no evidence levelCoprime integersdefinitionAddition of natural numbers, definition, no evidence levelAddition of natural n…definitionThe successor function is injective, statement, no evidence levelThe successor functio…statementZero is not a successor, statement, no evidence levelZero is not a success…statementCongruence is compatible with multiplication, statement, no evidence levelCongruence is compati…statementProof of the commutativity of addition by induction, proof, no evidence levelProof of the commutat…proofOrder on the natural numbers, definition, no evidence levelOrder on the natural …definitionCommutativity of addition, statement, no evidence levelCommutativity of addi…statementProof of strong induction from ordinary induction, proof, no evidence levelProof of strong induc…proofStrong induction, statement, no evidence levelStrong inductionstatementProof of the well-ordering principle from strong induction, proof, no evidence levelProof of the well-ord…proofWell-ordering principle, statement, no evidence levelWell-ordering princip…statementProof of the division algorithm, proof, no evidence levelProof of the division…proofDivision algorithm, statement, no evidence levelDivision algorithmstatementProof of Bézout's identity, proof, no evidence levelProof of Bézout's ide…proofBézout's identity, statement, no evidence levelBézout's identitystatementProof of the existence of inverses modulo n, proof, no evidence levelProof of the existenc…proofProof of the generalized Euclid's lemma, proof, no evidence levelProof of the generali…proofExistence of inverses modulo n, statement, no evidence levelExistence of inverses…statementGeneralized Euclid's lemma, statement, no evidence levelGeneralized Euclid's …statementProof of cancellation in congruences, proof, no evidence levelProof of cancellation…proofProof of Euclid's lemma, proof, no evidence levelProof of Euclid's lem…proofCancellation in congruences, statement, no evidence levelCancellation in congr…statementEuclid's lemma, statement, no evidence levelEuclid's lemmastatementProof of Wilson's theorem by pairing inverses, proof, no evidence levelProof of Wilson's the…proof
Each page uses the pages above it. The colour of the bar on a box shows how strong the evidence is, and the box also gives it as text. The list has the same pages.
  • no evidence level
  1. Definition by recursion concept
  2. Divisibility definition
  3. Mathematical induction concept
  4. Natural numbers object
  5. Peano axioms concept
  6. Congruence modulo n definition
  7. Greatest common divisor definition
  8. Prime number definition
  9. Successor function definition
  10. Modular multiplicative inverse definition
  11. Proof that congruence is compatible with multiplication proof
  12. Coprime integers definition
  13. Addition of natural numbers definition
  14. The successor function is injective statement
  15. Zero is not a successor statement
  16. Congruence is compatible with multiplication statement
  17. Proof of the commutativity of addition by induction proof
  18. Order on the natural numbers definition
  19. Commutativity of addition statement
  20. Proof of strong induction from ordinary induction proof
  21. Strong induction statement
  22. Proof of the well-ordering principle from strong induction proof
  23. Well-ordering principle statement
  24. Proof of the division algorithm proof
  25. Division algorithm statement
  26. Proof of Bézout's identity proof
  27. Bézout's identity statement
  28. Proof of the existence of inverses modulo n proof
  29. Proof of the generalized Euclid's lemma proof
  30. Existence of inverses modulo n statement
  31. Generalized Euclid's lemma statement
  32. Proof of cancellation in congruences proof
  33. Proof of Euclid's lemma proof
  34. Cancellation in congruences statement
  35. Euclid's lemma statement
  36. Proof of Wilson's theorem by pairing inverses proof

Where this leads

2 pages build on this one.

Further reading

  1. Web https://en.wikipedia.org/wiki/Wilson%27s_theorem, Elementary proof
About this page
TagRPE4ET6Y7B
URIm2://RPE4ET6Y7B
Kindproof
WritingW0 stub
MSC11A07
ProvesWilson's theorem
UsesPrime number, Congruence modulo n, Divisibility, Greatest common divisor, Existence of inverses modulo n, Modular multiplicative inverse, Division algorithm, Euclid's lemma, Cancellation in congruences, Congruence is compatible with multiplication
MethodsProof by cases
Changed4 November 2026

Markdown · JSON · Edit on GitHub

What this page needs for W1

  • an inventory row: the row of the inventory that the node accounts for (0 of 1)

The writing levels say how complete the text of a page is. They do not measure its truth.

What links here

No page links to this page yet.