MODULE 5 Fermat’s Theorem INTRODUCTION Fermat’s most important work was done in the development of modern number theory which was one of his favourite areas in math. He is best remembered for his number theory, in particular for Fermat’s last theorem. Fermat’s last theorem is the most famous solved problems in the history of mathematics, familiar to all mathematicians, and had achieved a recognizable status in popular culture prior to its proof. OBJECTIVES: At the end of this chapter, you should be able to: 1. use the Fermat’s factorization method to factor large integers; 2. applying Little’s Fermat’s theorem deduce Fermat’s theorem ; and 3. determine whether a given number is prime using Wilson’s theorem. 5.1 PIERRE de FERMAT Pierre de Fermat was born in Beaumont-de-Lomagne, france in August of 1601 and died in 1665. He is considered to be one of the greatest mathematicians of the seventeenth century. Mathematics was a hobby for Fermat. He sent many of his papers by mail to some of the best mathematicians in France. It was his link with Marin Mersenne that gave Fermat his international reputation. Fermat loved to dabble in math and rarely provide his proofs, he would state theorems but neglected the 58 proofs. In fact, his most famous work “ Fermat’s last theorem” remained without a proof until 1993 when Andrew J. Wiles provided the first proof. 5.2 FERMAT’S FACTORIZATION METHOD In 1643, Pierre de Fermat described a technique for factoring large numbers. This represented the first real improvement over the classical method of attempting to find a prime factor of n by dividing by all primes not exceeding √n . Fermat’s factorization scheme has at its heart the observation that the search for factors of an odd integer n is equivalent to obtaining integral solutions x and y of the equation n = x2 – y2 if n is the difference of two squares, then n can be factored as n = x2 – y2 = ( x + y ) ( x – y ) . Conversely, when n has the factorization n = ab, with a ≥ b ≥ 1, then we may write 2 2 a+b a−b ) − ( ) n= ( 2 2 Moreover, because n is taken to be an odd integer, a and b are themselves 𝑎+𝑏 𝑎−𝑏 odd; hence and will be nonnegative integers. 2 2 One begins the search for possible x and y satisfying the equation n = x – y2, or what is the same thing, the equation 2 x2 – n = y2 by first determining the smallest integer k for which k2 ≥ n. Now look successively at the numbers k2 – n, (k + 1)2 – n, (k + 2)2 – n, (k + 3)2 – n, . . . until a value of m ≥ √n is found making m2 – n a square. The process cannot go on indefinitely, since we eventually arrive at 2 n+1 n−1 ( ) − 𝑛= ( ) 2 2 59 2 the representation of n corresponding to the trivial factorization n = n 1. If this point is reached without a square difference having been discovered earlier, then n has no factors other than n and 1, in this case n is a prime number. Example: To illustrate the application of Fermat’s method, let us factor the integer n = 119143. Form a table of square, we find that 3452 < 119143 < 3462; thus it suffices to consider values of k2 – 119143 for k in the range 346 k < (119143 + 1)/ 2 = 59572. The calculations begin as follows: 3462 – 119143 = 111716 – 119143 = 573 , 3472 – 119143 = 120409 – 119143 = 1266, 3482 – 119143 = 121104 – 119143 = 1961, 3492 – 119143 = 121801 – 119143 = 2658, 3502 – 119143 = 122500 – 119143 = 3357, 3512 – 119143 = 123201 – 119143 = 4058, 3522 – 119143 = 123904 – 119143 = 4761 = 692. The last line exhibits the factorization 119143 = 3522 - 692 = (352 + 69 ) ( 352 – 69 ) 119143 = 421 283 In seven trials, we have obtained the prime factorization of the number 119143 which is equal to 421 283. SCQ1: Find the prime factors of 57,479 using the Fermat’s factorization method. 60 Activity 5.1 1. Find the prime factorization of the following using the Fermat’s factorization method. a. 2279 c. 340663 b. 10541 d. 554125 2. Factor the number 211 – 1 by Fermat’s factorization method. 61 5.3 LITTLE FERMAT’S THEOREM Little Fermat’s theorem is often used in number theory in the testing of large primes and simply states that: If p is a prime which does not divide a, then ap -1 1(mod p). In more simple language this say’s that if p is a prime that is not a factor of a, then when a is multiplied together p -1 times, and the result divided by p, we get a remainder of one. For example, if we use a = 7 and p =3, the rule says that 72 divided by 3 will have a remainder of one. In fact 49/3 does not have remainder of one. This theorem has since become known as “Fermat’s Little Theorem,” or just “Fermat’s Theorem,” to distinguish it from Fermat’s “Great” or “ Last Theorem”. Theorem 5-1 (Fermat’s Little Theorem) If p is a prime and p does not divide a, then ap-1 1(mod p). Proof: (left as an exercise) Fermat’s theorem has many applications and is central to much of what is done in number theory. On one hand, it can be a labor-saving device in certain calculation. Another use of Fermat’s theorem is a tool in testing the primality of a given integer n. For, if it could be shown that the congruence an a (mod n) frails to hold for some choice of a, then n is necessarily composite. Example. Use Fermat’s theorem to determine if 117 is a prime or composite. Solution: The computation is kept under control by selecting a small integer for a; say a = 2. Since 2117 may be written as 2117 = 2(7)(16) + 5 2117 = (27)16 25 and 27 = 128 11(mod 117) 62 2117 1116. 25 (121)8 25 48. 25 221(mod 117). But 221 = (27)3, which leads to 221 113 121 . 11 4 . 11 44(mod 117) Combining these congruences we finally obtain 2117 44 2(mod 117), so that 117 must be composite; actually, 117 = 13 9. SCQ2: Use Fermat’s theorem to prove: If p is a prime, then (a ± b)p a ± bp(mod p). p 63 Activity 5.2 1. Use Fermat’s theorem to determine if 123 is a prime or composite. 2. Use Fermat’s Theorem to verify that 17 divides 11104 + 1. 3. Find the units digit of 3100 by the use of Fermat’s Theorem. 64 5.4 WILSON’S THEOREM In the Meditations Alagebraicae of 1770, the English mathematician Edward waring(1741-1793) announced se3veral theorems. Among these is an interesting property of primes reported to him by one of his former students, a certain John Wilson. The first proof of the theorem was given by J.L. Lagrance in a treatise that appeared in 1770. Theorem 5-2 (Wilson’s Theorem) If p is a prime then (p - 1)! -1(mod p) Proof: Suppose that a is any one of the p – 1 positive integers 1, 2, 3, 4, 5, . . . , p – 1 and consider the linear congruence ax 1(mod p). Then gcd(a, p) = 1. By Theorem 4-4, this congruence admits a unique solution modulo p; hence, there is a unique integer a’, with 1 ≤ a’ ≤ p – 1, satisfying aa’ 1(mod p). Since p is a prime, a = a’ if and only if a = 1 or a = p – 1. Indeed, the congruence a2 1(mod p) is equivalent to (a - 1).(a + 1) 0(mod p). Therefore, either a – 1 0(mod p), in which case a = 1, or else a + 1 0(mod p), in which case a = p – 1. If we omit the numbers 1 and p – 1, the effect is to group the remaining integers 2, 3, 4, . . ., p -2 into pairs a, a’ , where a a’, such that their product aa’ 1(mod p). When these (p – 3)/2 congrueneces are multiplied together and the factors rearranged, we get 2 . 3 . 4 . . . (p - 2) 1(mod p) or rather (p – 2)! 1 (mod p). Now multiply by p – 1 to obtain the congruence (p – 1)! p – 1 -1 (mod p), as was to be proved. 65 The theorem is easily verified for small values of p. To illustrate, a. (2 – 1)! -1(mod 2) 1 -1(mod 2) b. (3 – 1)! -1(mod 3) 2 -1(mod 2) c. (5 – 1)! -1(mod 5) 4 ! -1(mod 5) 24 -1(mod 5) Example. Let p = 13, using Wilson’s Theorem show that (13 – 1)! -1(mod 13) Solution: It is possible to divide the integers 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 into (p – 3)/2 = 5 pairs each of whose products is congruent to 1 modulo 13. To write these congruences out explicitly: 2 7 1(mod 13) 3 9 1(mod 13) 4 10 1(mod 13) 5 8 1(mod 13) 6 11 1(mod 13) Multiplying the above congruences gives the result (2 7) (3 9) (4 10) (5 8) (6 11) 1(mod 13) 11! 1(mod 13) 66 and so 12! 12 -1(mod 13) (13 – 1)! -1(mod 13) Thus, (p - 1)! -1(mod p), with p =13. Activity 5.3 4. Find the remainder when 15! is divided by 17. 5. Show that 16! -1(mod 17). 6. Find two odd primes p ≤ 13 for which the congruence ( p – 1)! -1(mod p2) holds. 67