Chapter 5: Fermat’s Little Theorem 1 Chapter 5: Fermat’s Theorem SECTION A Introduction to Fermat’s Little Theorem By the end of this section you will be able to prove Fermat’s Little Theorem apply Fermat’s Little Theorem to congruences prove properties of congruences A1 Table of Indices In this section we evaluate exponents or indices in modular arithmetic. In this section we confine ourselves to a prime modulus. First we develop a table of values and then we will state and prove an important result involving a particular index with a prime modulus. Example 1 Develop a table of values for the 5 powers of each non-zero residue modulo 5. Solution We work out the powers of the least non-negative residues modulo 5. Hence we have: 1 2 3 4 n 2 2 2 2 2 n 1 1 mod 5 2 4 mod 5 3 4 mod 5 4 1 mod 5 n3 13 1 mod 5 23 3 mod 5 33 2 mod 5 43 4 mod 5 n4 14 1 mod 5 24 1 mod 5 34 1 mod 5 44 1 mod 5 n5 15 1 mod 5 25 2 mod 5 35 3 mod 5 45 4 mod 5 TABLE 1 What do you notice about the shaded result? 14 24 34 44 1 mod 5 In general n 4 1 mod 5 provided that n is not divisible by 5. This is no coincidence but will also work with other prime moduli. For example you will find the following results: 112 212 312 412 512 612 712 812 912 1012 1112 1212 1 mod 13 This only works if we have a prime modulus and is not valid for any modulus and is an example of a general proposition called Fermat’s Little Theorem –FLT. A2 Statement and Proof of Fermat’s Little Theorem Fermat’s Little Theorem is a result which makes evaluating a power of a number to a prime modulus much easier. Fermat’s Little Theorem states that if p is prime and n is any integer such that p does not divide into n then n p 1 1 mod p Here are some more numerical examples: With prime p 11 and n 2 : 2111 210 1024 1 mod 11 With prime p 7 and n 5 : 57 1 56 15625 1 mod 7 Chapter 5: Fermat’s Little Theorem 2 With prime p 17 and n 15 : 1517 1 1516 2 16 mod 17 4 4 2 mod 17 16 mod 17 4 1 mod 17 1 mod 17 Just because this works for these three examples it does not mean the result is generally true. How can we say that this is always the case? We need to prove this result - Fermat’s Little Theorem. Fermat’s Little Theorem (5.1). Let n be an integer and p be a prime number which does not divide n. Then n p 1 1 mod p 4 Proof. We examine the first p 1 positive multiples of n: n, 2n, 3n, 4n, , p 1 n (*) Each of these are incongruent modulo p. This means that none of these are congruent to each other modulo p. Why? Suppose there are two which are congruent to each other: kn mn mod p where 1 k m p 1 Then by Corollary (4.10) on page 12 of the last chapter which claims: If ac bc mod p and prime p does not divide into c then a b mod p . We have k m mod p which is impossible because 1 k m p 1 . Multiplying the numbers in the list (*) gives n 2n 3n 4n p 1 n 1 2 3 p 1 n n n n mod p p 1 copies p 1 !n p 1 mod p Since the numbers in the list (*) are not congruent to each other so each of these numbers is congruent to 1, 2, 3, 4, …, p 1 in some order. This means that we have p 1!n p 1 1 2 3 4 p 1 mod p p 1 ! mod p Applying Corollary (4.10) again to p 1 !n p 1 p 1 ! mod p with c p 1 ! gives: n p 1 1 mod p This is our required result. ■ Fermat’s Little Theorem is useful is simplifying calculations. Why? Because evaluating powers of numbers can be a tedious task so if we have a prime modulus then we want to work with n p 1 1 mod p . Chapter 5: Fermat’s Little Theorem 3 A3 Application of Fermat’s Little Theorem Example 2 Find the least non-negative residue x in the following congruence 352 x mod 11 . Solution Since 11 is prime we can apply FLT: n p 1 1 mod p With n 3 and p 11 we have 310 1 mod 11 Rewriting the given index of 52 in terms of 10: 52 5 10 2 Hence we have 352 35032 mod 11 310 32 mod 11 5 1 9 mod 11 9 mod 11 5 This means that x 9 mod 11 . Example 3 Determine the least non-negative residue x in the following congruence 5101 x mod 31 . Solution Since 31 is prime we can apply FLT: n p 1 1 mod p With n 5 and p 31 we have 530 1 mod 31 Rewriting 101 3 30 11 in 5101 x mod 31 gives 5101 530 511 mod 31 3 13511 mod 31 511 mod 31 Need to write 511 as the least non-negative residue modulo 31. Note that 53 125 3 31 1 which means that 53 1 mod 31 Hence 5101 511 mod 31 53 52 1 25 25 mod 31 3 We have x 25 mod 31 . Example 4 Let p be prime and n be a non-zero residue modulo p. Show that the n p 2 is the multiplicative inverse of n modulo p. Solution Chapter 5: Fermat’s Little Theorem 4 What does the multiplicative inverse mean? By Definition (4.15) on Page 22 of the last section we have: If ax 1 mod n and gcd a, n 1 then the unique solution of this congruence is called the multiplicative inverse of a modulo n. In our case we examine nx 1 mod p and need to show that x n p 2 mod p . By FLT we have n p 1 1 mod p n n p 2 1 mod p Equating the last line to nx 1 mod p : nx n n p 2 mod p By Corollary (4.10) on page 12 of the last chapter which claims: If ac bc mod p and prime p does not divide into c then a b mod p . We have our required result x n p 2 mod p which means that the multiplicative inverse of n modulo p is n p 2 mod p . ■ Corollary (5.2). Let n be an integer and p be a prime number. Then n p n mod p How is this result different from FLT? In FLT the prime p did not divide integer n. How do we prove this result? Consider two cases: 1) p does divide n 2) p does not divide n Case 1 Assume prime p does divide n, p n then n 0 mod p implies n p 0 mod p Hence we have our result n p n mod p . Case 2 Assume prime p does not divide into n then we can use FLT (5.1): Let n be an integer and p be a prime number which does not divide n. Then n p 1 1 mod p Multiply this by n gives nn p 1 n 1 mod p n p n mod p This is our required result. ■ A4 Pseudoprimes Is the converse of FLT true? This means we need to check that if n m 1 1 mod m then m is prime. Let m 561 and n 2 then by evaluation we find that Chapter 5: Fermat’s Little Theorem 5 2560 1 mod 561 However 561 3 11 17 which means 561 is composite. The converse of FLT does not hold, that means n m 1 1 mod m does not imply that m is prime We call numbers like 561 a pseudoprime. Another pseudoprime is 341 which is composite because 341 11 31 . However 2340 1 mod 341 There is a difference between the pseudoprime 341 and 561. Examine the following results for 341: 3340 56 mod 341 , 5340 67 mod 341 , 7340 56 mod 341 , 23340 1 mod 341 None of the base numbers 3, 5, 7 and 23 divide into 341. These do not always give n m 1 1 mod m . For 561 this result works for every base number n provided it does not divide into 561. Hence n560 1 mod 561 provided n does not divide 561. The number 561 is called a Carmichael number. These are composite numbers m such that to every base n we have n m 1 1 mod m . SUMMARY FLT (5.1). Let n be an integer and p be a prime number which does not divide n. Then n p 1 1 mod p We can use this result to simplify powers of prime moduli.