This article collects together a variety of proofs of Fermat's little theorem, which states that
for every prime number p and every integer a (see modular arithmetic).
Simplifications
Some of the proofs of Fermat's little theorem given below depend on two simplifications.
The first is that we may assume that is in the range . This is a simple consequence of the laws of modular arithmetic; we are simply saying that we may first reduce modulo . This is consistent with reducing modulo , as one can check.
Secondly, it suffices to prove that
for in the range . Indeed, if the previous assertion holds for such , multiplying both sides by yields the original form of the theorem,
On the other hand, if or , the theorem holds trivially.
Combinatorial proofs
Proof by counting necklaces
This is perhaps the simplest known proof, requiring the least mathematical background. It is an attractive example of a combinatorial proof (a proof that involves counting a collection of objects in two different ways).
The proof given here is an adaptation of Golomb's proof.
To keep things simple, let us assume that is a positive integer. Consider all the possible strings of symbols, using an alphabet with different symbols. The total number of such strings is , since there are possibilities for each of positions (see rule of product).
For example, if and , then we can use an alphabet with two symbols (say and ), and there are strings of length 5: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , .
We will argue below that if we remove the strings consisting of a single symbol from the list (in our example, and ), the remaining strings can be arranged into groups, each group containing exactly strings. It follows that is divisible by .
Necklaces
Let us think of each such string as representing a necklace. That is, we connect the two ends of the string together and regard two strings as the same necklace if we can rotate one string to obtain the second string; in this case we will say that the two strings are friends. In our example, the following strings are all friends: , , , , . In full, each line of the following list corresponds to a single necklace, and the entire list comprises all 32 strings. , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , . Notice that in the above list, each necklace with more than one symbol is represented by 5 different strings, and the number of necklaces represented by just one string is 2, i.e. is the number of distinct symbols. Thus the list shows very clearly why is divisible by .
One can use the following rule to work out how many friends a given string has: If is built up of several copies of the string , and cannot itself be broken down further into repeating strings, then the number of friends of (including itself) is equal to the length of .
For example, suppose we start with the string , which is built up of several copies of the shorter string . If we rotate it one symbol at a time, we obtain the following 3 strings: , , . There aren't any others, because is exactly 3 symbols long and cannot be broken down into further repeating strings.
Completing the proof
Using the above rule, we can complete the proof of Fermat's little theorem quite easily, as follows. Our starting pool of strings may be split into two categories: Some strings contain identical symbols. There are exactly of these, one for each symbol in the alphabet. (In our running example, these are the strings and .) The rest of the strings use at least two distinct symbols from the alphabet. If we can break up into repeating copies of some string , the length of must divide the length of . But, since the length of is the prime , the only possible length for is also . Therefore, the above rule tells us that has exactly friends (including itself).
The second category contains strings, and they may be arranged into groups of strings, one group for each necklace. Therefore, must be divisible by , as promised.
Proof using dynamical systems
This proof uses some basic concepts from dynamical systems.
We start by considering a family of functions Tn(x), where n ≥ 2 is an integer, mapping the interval [0, 1] to itself by the formula
where { y} denotes the fractional part of y. For example, the function T3(x) is illustrated below: