Fermat s Little Theorem Theorem (Fermat s Little Theorem): Let p be a prime. Then p n p n (1) for any integer n 1. Proof: We distinguish two cases. Case A: Let p n, then, obviously, p n p n, and we are done. Case B: Let p n. (2) Consider the following numbers: By the Division Algorithm we have n, 2n, 3n,..., (p 1)n. n = pk 1 + r 1 p n r 1 2n = pk 2 + r 2 p 2n r 2 3n = pk 3 + r 3... p 3n r 3... (3) (p 1)n = pk p 1 + r p 1 p (p 1)n r p 1 where 0 r i p 1. Moreover, r i 0, since otherwise p in, and therefore by Euclid d Lemma p i or p n. But this is impossible, since p > i and p n by (2). So, Lemma 1: Let a, b, c, d, and p be integers such that Then p (ac bd). Proof: We have 1 r i p 1. (4) p (a b) and p (c d). (5) ac bd = ac bc + bc bd = c(a b) + b(c d). By (5) the right-hand side is divisible by p. Therefore the left-hand side is also divisible by p. By Lemma 1 we can multiply out all terms from the right-hand column of (3). We have p [n 2n 3n... (p 1)n r 1 r 2... r p 1 ] p [(p 1)!n p 1 r 1 r 2... r p 1 ]. (6) 1
Lemma 2: We have Proof: We first show that r 1 r 2... r p 1 = (p 1)!. (7) r 1, r 2,..., r p 1 are all distinct. (8) In fact, assume to the contrary that there are some r i and r j with r i = r j. Then by (3) we have in pk i = jn pk j, hence (i j)n = p(k i k j ). This means that p divides (i j)n. From this by Euclid s Lemma it follows that p (i j) or p n. But this is impossible, since p > i j by (4) and p n by (2). This contradiction proves (8). So, we have p 1 distinct numbers between 1 and p 1. This means that which gives (7). By (6) and (7) we obtain {r 1, r 2,..., r p 1 } = {1, 2,..., p 1}, p [(p 1)!n p 1 (p 1)!]. p (p 1)!(n p 1 1). p 1 2... (p 1)(n p 1 1). Since p divides the product, by Euclid s Lemma it follows that p divides at least one of its terms. Note that p 1, p 2,..., p (p 1). Therefore p (n p 1 1), hence p (n p n). Congruences Definition: Let m be a positive integer. Then integers a and b are congruent modulo m, denoted by a b mod m, if m (a b). Example: 3 1 mod 2, 6 4 mod 2, 14 0 mod 7, 25 16 mod 9, 43 27 mod 35. Properties: Let m be a positive integer and let a, b, c, d be integers. Then 1. a a mod m 2. If a b mod m, then b a mod m. 3. If a b mod m and b c mod m, then a c mod m. 4. (a) If a qm + r mod m, then a r mod m. (b) Every integer a is congruent mod m to exactly one of 0, 1,..., m 1. 5. If a b mod m and c d mod m, then a ± c b ± d mod m and ac bd mod m. 2
5. If a b mod m, then a ± c b ± c mod m and ac bc mod m. 5. If a b mod m, then a n b n mod m for any n Z +. 6. If (c, m) = 1 and ac bc mod m, then a b mod m. Proof 2 of Fermat s Little Theorem: We distinguish two cases. Case A: Let p n, then, obviously, p n p n, and we are done. Case B: Let p n. Consider the following numbers: n, 2n, 3n,..., (p 1)n. We have n r 1 mod p 2n r 2 mod p 3n r 3 mod p... (p 1)n r p 1 mod p, (9) where 0 r i p 1. Moreover, r i 0, since otherwise p in, and therefore by Euclid d Lemma p i or p n. But this is impossible, since p > i and p n. So, 1 r i p 1. From (9) by property 5 we have n 2n 3n... (p 1)n r 1 r 2... r p 1 mod p (p 1)!n p 1 r 1 r 2... r p 1 mod p. (10) By Lemma 2 we have r 1 r 2... r p 1 = (p 1)!. (11) By (10) and (11) we obtain (p 1)!n p 1 (p 1)! mod p. Since (p, (p 1)!) = 1, from this by by property 6 we get n p 1 1 mod p, hence n p n mod p by property 4. This means that n p n is divisible by p. 3
Theorem (Fermat s Little Theorem): Let p be a prime. Then for any integer n 1. p n p n (1)
Proof: We distinguish two cases. Case A: Let p n, then, obviously, p n p n, and we are done. Case B: Let p n. (2) Consider the following numbers: n, 2n, 3n,..., (p 1)n. By the Division Algorithm we have n = pk 1 + r 1 2n = pk 2 + r 2 3n = pk 3 + r 3... (p 1)n = pk p 1 + r p 1 p n r 1 p 2n r 2 (3)... p (p 1)n r p 1 where 0 r i p 1. Moreover, r i 0, since otherwise p in, and therefore by Euclid d Lemma p i or p n. But this is impossible, since p > i and p n by (2). So, 1 r i p 1. (4)
Lemma 1: Let p, a, b, c, and d be integers such that p (a b) and p (c d). (5) Then p (ac bd). Proof: We have ac bd = ac bc + bc bd = c(a b) + b(c d). The right-hand side is divisible by p by (5). Therefore the left-hand side is also divisible by p.
By Lemma 1 we can multiply out all terms from the right-hand column of (3). We have p [n 2n... (p 1)n r 1 r 2... r p 1 ] p [(p 1)!n p 1 r 1 r 2... r p 1 ]. (6)
Lemma 2: We have r 1 r 2... r p 1 = (p 1)!. (7) Proof: We first show that r 1, r 2,..., r p 1 are all distinct. (8) In fact, assume to the contrary that there are some r i and r j with r i = r j. Then by (3) we have in pk i = jn pk j, hence (i j)n = p(k i k j ). This means that p divides (i j)n. From this by Euclid s Lemma it follows that p (i j) or p n. But this is impossible, since p > i j by (4) and p n by (2). This contradiction proves (8). So, we have p 1 distinct numbers between 1 and p 1. This means that {r 1, r 2,..., r p 1 } = {1, 2,..., p 1}, which gives (7).
By (6) and (7) we obtain p [(p 1)!n p 1 (p 1)!]. p (p 1)!(n p 1 1). p 1 2... (p 1)(n p 1 1). Since p divides the product, by Euclid s Lemma it follows that p divides at least one of its terms. Note that p 1, p 2,..., p (p 1). Therefore p (n p 1 1), hence p (n p n).
CONGRUENCES Definition: Let m be a positive integer. Then integers a and b are congruent modulo m, denoted by if m (a b). a b mod m, Example: 3 1 mod 2, 6 4 mod 2, 14 0 mod 7, 25 16 mod 9, 43 27 mod 35.
Properties: Let m be a positive integer and let a, b, c, and d be integers. Then 1. a a mod m 2. If a b mod m, then b a mod m. 3. If a b mod m and b c mod m, then a c mod m. 4. (a) If a qm + r mod m, then a r mod m. (b) Every integer a is congruent mod m to exactly one of 0, 1,..., m 1.
5. If a b mod m and c d mod m, then and a ± c b ± d mod m ac bd mod m. 5. If a b mod m, then and a ± c b ± c mod m ac bc mod m. 5. If a b mod m, then a n b n mod m for any n Z +. 6. If (c, m) = 1 and ac bc mod m, then a b mod m.
Proof 2 of Fermat s Little Theorem: We distinguish two cases. Case A: Let p n, then, obviously, p n p n, and we are done. Case B: Let p n. Consider the following numbers: n, 2n, 3n,..., (p 1)n. We have n r 1 mod p 2n r 2 mod p... (p 1)n r p 1 mod p, (9) where 0 r i p 1. Moreover, r i 0, since otherwise p in, and therefore by Euclid d Lemma p i or p n. But this is impossible, since p > i and p n. So, 1 r i p 1.
From (9) by property 5 we have n 2n... (p 1)n r 1 r 2... r p 1 mod p (p 1)!n p 1 r 1 r 2... r p 1 mod p. (10) By Lemma 2 we have r 1 r 2 r 3... r p 1 = (p 1)!. (11) By (10) and (11) we obtain (p 1)!n p 1 (p 1)! mod p. Since (p, (p 1)!) = 1, from this by by property 6 we get n p 1 1 mod p, hence n p n mod p by property 4. This means that n p n is divisible by p.