Wilson’s Theorem definition
Wilson’s theorem says that an integer n greater than 1 is prime exactly when (n − 1)! is congruent to −1 modulo n.
Wilson’s Theorem in a picture
How it works
For a prime p, each nonzero residue modulo p has a multiplicative inverse. The residues can be paired with their inverses, except for 1 and −1, which are their own inverses. Their product is −1 modulo p. For p = 2, the residues 1 and −1 coincide and the congruence still holds.
Worked examples
Check Wilson’s theorem for n = 7.
6! = 720. Its remainder modulo 7 is 6, which is congruent to −1.
What happens for n = 6?
5! = 120 has remainder 0 modulo 6, so the congruence fails.
Does the theorem require factorial n! or (n − 1)!?
It uses (n − 1)!. The factor n itself would force n! to have remainder zero.
Common mistake
The usual nonnegative remainder for −1 modulo n is n − 1. These are two names for the same residue class.
Quick check
What factorial is tested for n = 5?
Show answer
4!.
Does the condition characterize primes among integers greater than 1?
Show answer
Yes. The congruence holds exactly for primes.
Sources
Flashcard
Wilson’s Theorem
Reveal the definition
Wilson’s theorem says that an integer n greater than 1 is prime exactly when (n − 1)! is congruent to −1 modulo n.
Effortless Math. “Wilson’s Theorem.” Math Dictionary.



