Powers congruent to
Let and be coprime integers. Then there is some positive such that
There are only different residues modulo , so some two of the sequence must be congruent modulo (they can’t all be different).
Let’s say that , with .
But is invertible modulo , and so which gives that
That proof is a little bit nonconstructive: it tells us it exists, but doesn’t give very much help looking for it.
It turns out that that we can get an explicit result. First we’ll do a relatively easy case, valid when the modulus is prime.
[Fermat’s Little Theorem] Let be prime, and let be an integer coprime to . Then
Before we prove it, we’ll talk a while longer about invertible elements and multiplication modulo a prime.
Let’s start with an example, and consider the seven integers Regarded modulo 7, each is congruent to something different: Can we explain this systematically?
It comes down to the fact that is invertible modulo (with inverse , as ).
By multiplying congruences, so if we want to solve , we simply take .
So as there are seven numbers in the list, and one is congruent to each possible residue (modulo 7), they’re all different.
This is true in general, for the same reason: if is coprime to , then the integers contain each of the residues (and so exactly once each, because there’s of them).
Consider the product regarded up to congruence modulo .
One way of thinking about it is that it’s but with every term multiplied by an , so is congruent to .
Another is that, since the product contains a copy of every nonzero residue modulo , it is congruent to .
But, putting these observations together, we discover that But all the residues from to are invertible, and the product of invertible residues is invertible, so is invertible. Multiplying both sides by leaves us with exactly as promised.
Fermat’s Little Theorem should not be confused with Fermat’s Last Theorem. The latter says there are no solutions in positive integers to with , and was much, much harder to prove.
In the proof of Fermat’s Little Theorem, we multiplied one representative of each invertible residue class together. It turns out we can prove a substantially more general theorem, but it’s a little more complicated. First we need a definition:
Definition: Euler’s function (sometimes known as the totient function) is defined by taking to be the number of integers from to which are coprime to .
For example, if is prime, since every number from to is coprime to (and isn’t coprime to ).
For another example, , since and are the only numbers between and which are coprime to .
Using this concept, we can generalise Fermat’s Little Theorem considerably:
[Fermat-Euler Theorem] Let and be integers with . Then
The proof is exactly the same as Fermat’s Little Theorem, but instead of working with all the integers , we just consider those that are invertible modulo : let’s write these as .
If is invertible, then are all invertible too, and any invertible residue is of this form: can be written as . Hence are congruent to in some order.
Hence if we consider the products of these we have Since all the elements are invertible, we can cancel them out to get .