Wilson's theorem
A number p is prime exactly when (p − 1)! + 1 is divisible by p. History: stated 1770, proved by Lagrange.
How to work it out
- 1
The statement:
- 2
A number p is prime exactly when (p − 1)! + 1 is divisible by p.
- 3
Below, the numbers in the table are computed by this site from the definition, not copied.
LaTeX source of the formulas on this page
\[ (p-1)! \equiv -1 \pmod p \iff p \text{ is prime} \]Checking n = 2 to 12 (computed)
| n | (n−1)! mod n | Prime? |
|---|---|---|
| 2 | 1 | yes (−1) |
| 3 | 2 | yes (−1) |
| 4 | 2 | no |
| 5 | 4 | yes (−1) |
| 6 | 0 | no |
| 7 | 6 | yes (−1) |
| 8 | 0 | no |
| 9 | 0 | no |
| 10 | 0 | no |
| 11 | 10 | yes (−1) |
| 12 | 0 | no |
Questions
What is the wilson's theorem?
A number p is prime exactly when (p − 1)! + 1 is divisible by p.
Who is the Wilson's theorem associated with?
Joseph-Louis Lagrange.