In a previous post I explained four (mostly) equivalent statements of Fermat’s Little Theorem (which I will abbreviate “FlT”—not “FLT” since that usually refers to Fermat’s Last Theorem, whose proof I am definitely not qualified to write about!).
Today I want to present the first proof of FlT. We’re going to prove statement (2), that is,
If is a prime and is any integer not divisible by , then .
We already saw that statements (1), (2), and (3) are logically equivalent, so proving (2) is sufficient to prove all of them. (As I’ll show in a future post, we can also generalize this proof to prove the corrected version of statement (4).)
So, suppose is a prime, and is any integer not divisible by . Now consider the set of multiples of up to :
However, we will consider not the multiples of themselves but their remainders when divided by . As an example, suppose and . Then we want to look at multiples of : —and then take their remainders . As you can check, this yields the set
As another example, suppose and . Then the multiples of , considered , are , , , and so on, ultimately yielding the set of remainders (which you can again check):
Have you noticed anything about the previous examples? It looks like every possible remainder (other than ) shows up exactly once, (though obviously not in order). Will this always be true?
The fact that doesn’t show up is no mystery: we specified that is not divisible by , and in that case none of will be divisible by either, so none of them have a remainder of . But why would their remainders all be different?
Suppose there are two multiples of , say, and , which have the same remainder when divided by . We can write this as . Subtracting from both sides and factoring out , we find that , that is, is divisible by . Well, when a prime divides a product of two things, it must divide one or the other (or both). But we already assumed is not divisible by . Hence must evenly divide . But and are both less than , so their difference must lie strictly between and . The only multiple of strictly between and is zero, so , that is, . So the only way to have is if . Put the other way around, we’ve shown that if then and don’t have the same remainder . So this proves that all the multiples of from up to have different remainders when divided by .
Finally, since there are exactly multiples of in our set, and possible nonzero remainders , and all the remainders have to be different, we conclude that each remainder shows up exactly once.
So what? Here comes the clever trick: what happens if we take all those multiples of and multiply them all together, and then take the remainder ? Since taking remainders commutes with multiplication (that is, ), this is the same as if we first take their remainders and then multiply those. But we already know that the remainders will contain each number from to exactly once—and if we’re multiplying them then the order doesn’t matter. So,
that is, the product of all the multiples of has the same remainder as the factorial of when divided by . For example, looking at the example of and again, the product of the multiples of is , whereas ; but both have a remainder of when divided by .
Now, we can factor the copies of out of the left side, and we are left with
Now we just want to cancel from both sides—though we have to be a little careful when dividing both sides of a modular equation. In general it’s only valid when the thing you want to divide by is relatively prime to the modulus (this same issue came up in my previous post). But that is indeed the case here: is not divisible by (since is prime and is the product of a bunch of things that are all smaller than ). So we are justified in dividing both sides by it, and this completes the proof: