MathLabs
TheoremProved

Wilson's theorem

Statement

A natural number p>1p>1 is prime if and only if (p−1)!≡−1(modp)(p-1)! \equiv -1 \pmod{p}.

Why is it true?

Modulo a prime pp, every residue from 11 to p−1p-1 pairs off with its multiplicative inverse, and only 11 and p−1≡−1p-1\equiv-1 are their own inverses. Multiplying all residues, the self-paired ones survive and the rest cancel in inverse pairs, leaving (p−1)!≡−1(p-1)!\equiv -1.

Proof sketch

(⇒\Rightarrow) For prime pp, pair each k∈{2,…,p−2}k\in\{2,\dots,p-2\} with its inverse mod pp (never itself, since x2≡1(modp)x^2\equiv1\pmod p only for x≡±1x\equiv\pm1); these pairs multiply to 11, leaving (p−1)!≡1⋅(p−1)≡−1(modp)(p-1)!\equiv 1\cdot(p-1)\equiv -1\pmod p. (⇐\Leftarrow) If nn is composite with a proper divisor 1<d<n1<d<n, then dd appears as a factor in (n−1)!(n-1)!, so d∣(n−1)!d\mid(n-1)! and (n−1)!≢−1(modn)(n-1)!\not\equiv-1\pmod n.

Proved by

Topics that use this theorem

Related theorems

Step-by-step proofs

No step-by-step proof yet for this theorem.

References

  1. G. H. Hardy, E. M. Wright (2008). An Introduction to the Theory of Numbers
  2. Carl B. Boyer, Uta C. Merzbach (2011). A History of Mathematics