ELI5: Explain Like I'm 5

Proofs of Fermat's little theorem

Okay, so imagine you have a bunch of candies, and you want to share them equally among your friends. Fermat's little theorem helps you figure out how many candies each person would get.

But how does it work? Well, let's say you have 10 candies and 4 friends. You could give each friend 2 candies, right? But what if you had 11 candies? If you tried to divide them equally among your 4 friends, there would always be one leftover candy.

Fermat's little theorem says that if you have a number (let's call it "a") and you want to divide it by another number (let's call it "p"), then the remainder will always be the same no matter what value of "a" you choose. This remainder is called the "mod" or "modulo", and it's written as "a mod p".

For example, if you want to divide 7 by 4, the remainder would be 3. This is written as "7 mod 4 = 3".

Now here's where things get a little complicated for our young minds: Fermat's little theorem says that if you take a number "a" and raise it to the power of "p-1" (where "p" is a prime number), and divide it by "p", the remainder will always be 1. This is called "a^p-1 mod p = 1".

Let's try an example. If we take the number 3 and raise it to the power of 5 (since we're using p=5), we get 243. If we divide 243 by 5, the remainder is 3. But if we raise 3 to the power of 4 (since 5-1=4), we get 81. And if we divide 81 by 5, the remainder is 1! So 3^4 mod 5 = 1.

Whew, that was a lot to take in! But basically, Fermat's little theorem helps us understand how to divide numbers equally and predict what the remainder will be. And it has lots of uses in math and cryptography!