Kolton Ndoj

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.

ap≡a(modp)(p prime)a^{p}\equiv a\pmod p\quad(p\text{ prime})

What the symbols mean

pp
a prime number
aa
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

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.

Related

Play with it live →

Math · Number theory · Stretch