1.2.3. Fermat’s Little Theorem
This section is based on part of [BUR11, Sec. 5.2].
Theorem 1.2.3.1 (Fermat’s Little Theorem).
Let be a prime and . Then
Proof.
The case is trivially true since . Suppose that . We may assume that . Indeed, if , then , while if is odd, then and
We prove the claim by induction on . The case is clear since . Inductively, let and suppose that . We need to prove that
By the Binomial Theorem,
If and , then
is divisible by (notice that divides but does not divide , and apply Theorem 1.1.4.2). Hence, and therefore
Since , the induction hypothesis yields the required congruence. ∎
Corollary 1.2.3.2.
Let be a prime and be such that . Then
Proof.
By Fermat’s Little Theorem (Theorem 1.2.3.1), the congruence holds. Using Corollary 1.2.1.11, we may cancel on both sides to obtain
Warning 1.2.3.3.
As stated, Fermat’s Little Theorem (Theorem 1.2.3.1) and its corollary (Corollary 1.2.3.2) are false for arbitrary composite moduli: for example, let and . Then
but . There is, however, a suitable generalisation of Corollary 1.2.3.2 that we study later in Section 1.2.6.
Fermat’s Little Theorem (Corollary 1.2.3.2) can be used to simplify certain calculations.
Example 1.2.3.4.
Let . Suppose that one is interested in solving the linear congruence
Since , this congruence is equivalent to the congruence
Also, since , we have
Since , Fermat’s Little Theorem (Corollary 1.2.3.2) yields the congruence
Hence,
Therefore, the original linear congruence is equivalent to the linear congruence
which clearly has as a solution, and this solution is unique modulo (Corollary 1.2.2.7).
Fermat’s Little Theorem (Corollary 1.2.3.2) provides a necessary condition for an integer to be prime without exhibiting a proper divisor: if is prime, then for every with we must have . This condition can sometimes be checked by hand, as we show in the following example.
Example 1.2.3.5.
Not covered in the lectureLet and . By Proposition 1.2.1.12, we have . If is prime, by Fermat’s Little Theorem (Corollary 1.2.3.2) we must have
We show that this is not the case. We first observe that and therefore . Using that , we obtain the congruence
Moreover, since , that is,
Multiplying the latter congruence by , we obtain
We now notice that and therefore
We summarise our computations in the congruence
Using this last congruence and the factorisation , we obtain the simplified congruence
Finally, and therefore . Combining the above, we obtain the congruence
Since , the integer is composite (otherwise we would obtain a contradiction to Fermat’s Little Theorem (Corollary 1.2.3.2)). Indeed, . The factorisation of can be found more directly by trial division since ; see Corollary 1.1.4.11.
Remark 1.2.3.6.
We come back to Fermat’s Little Theorem (Theorem 1.2.3.1) and its corollary (Corollary 1.2.3.2) in Section 1.4.1.