Number System

Wilson’s Theorem

Students pair wooden counters in a row, leaving distinct endpoint tokens.

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.

In Spanish
teorema de Wilson
Topic
Prime numbers and number theory

Wilson’s Theorem in a picture

Wilson’s Theorem diagramFor p = 5, (5 − 1)! = 24, which leaves remainder 4, or −1 modulo 5.Use n = 5Form the factorial of n − 14! = 1 × 2 × 3 × 4 = 24Divide 24 by 5 and take the remainder24 ≡ 4 ≡ −1 mod 5The congruence holds
For p = 5, (5 − 1)! = 24, which leaves remainder 4, or −1 modulo 5.

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 should (p − 1)! leave as the nonnegative remainder modulo a prime p?

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.