Fermat's little theorem
Raise any number to a prime power and you get back the same number on a clock of that prime size.
What the symbols mean
- a prime number
- any whole number
Why it works — the picture
Make necklaces of p beads, each bead one of a colours: there are a^p colour sequences. Spin a necklace and you get another sequence. The a single-colour necklaces never change; every other necklace belongs to a family of exactly p different spins (this is where p being prime matters). So a^p minus a is a whole number of families of p, a multiple of p. For p = 7, a = 2: 2^7 = 128 = 18x7 + 2.
Try it yourself
- Check 3^5 = 243 leaves remainder 3 mod 5.
- Find the remainder of 2^100 mod 7.
- Test p = 6 (not prime) with a = 2: does it still work?
Where it’s used in real life
It is the engine of RSA encryption, which protects online payments.
The story behind it
Pierre de Fermat stated it in 1640, and Euler gave the first published proof in 1736.