* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Modular Arithmetic
Survey
Document related concepts
Large numbers wikipedia , lookup
Vincent's theorem wikipedia , lookup
List of important publications in mathematics wikipedia , lookup
Mathematical proof wikipedia , lookup
Georg Cantor's first set theory article wikipedia , lookup
Factorization of polynomials over finite fields wikipedia , lookup
Fundamental theorem of calculus wikipedia , lookup
Four color theorem wikipedia , lookup
Elementary mathematics wikipedia , lookup
List of prime numbers wikipedia , lookup
Wiles's proof of Fermat's Last Theorem wikipedia , lookup
Collatz conjecture wikipedia , lookup
Fundamental theorem of algebra wikipedia , lookup
Fermat's Last Theorem wikipedia , lookup
Transcript
MATH 289 WINTER 2011 PROBLEM SET 5: MODULAR ARITHMETIC 1. Congruence Suppose that m is an integer. We say that a is congruent to b modulo m if m divides the difference a − b. The notation we use is a ≡ b(mod m). Congruence modulo m is an equivalence relation. This means it has the following 3 properties for all a, b, c ∈ Z: (1) a ≡ a(modm); (2) If a ≡ b(modm) then b ≡ a(modm); (3) If a ≡ b(modm) and b ≡ c(modm) then a ≡ c(modm). The following is easy to prove: Lemma 1. a1 ≡ b1 (mod m) and a2 ≡ b2 (mod m) then a1 + a2 ≡ b1 + b2 (mod m) and a1 a2 ≡ b1 b2 (mod m). For an integer a and a positive integer m, we define the congruence class of a modulo m by [a]m = {b ∈ Z | b ≡ a(modm)} = {. . . , a − 2m, a − m, a, a + m, a + 2m, . . . }. It is easy to verify that the following statements are equivalent: (1) a ≡ b(modm); (2) b ∈ [a]m ; (3) a ∈ [b]m ; (4) [a]m = [b]m ; (5) [a]m ∩ [b]m 6= ∅. If a ∈ Z then we can write a = qm + r where 0 ≤ r < m. It follows that [a]m = [r]m . So the only congruence classes modulo m are: [0]m , [1]m , . . . , [m − 1]m . These congruence classes are distinct: suppose that [i]m = [j]m for 0 ≤ i < j < m. Then we get m | (j − i) and 0 ≤ j − i < m. Therefore we have j − i = 0 and i = j. We denote the set of congruence classes by Zm . So Zm has exactly m elements. We now can define addition and multiplication of congruence classes by: Definition 2. If a, b ∈ Z, then we define [a]m + [b]m := [a + b]m [a]m · [b]m := [a · b]m . 1 One has to check that this is well-defined. Suppose that [a]m = [a0 ]m and [b]m = [b0 ]m , then we need that [a0 + b0 ]m = [a + b]m and [a0 · b0 ]m = [a · b]m . This follows Lemma 1. One can define subtraction for congruence classes in a similar way. If it is clear that we are computing modulo m, then we will sometimes write a instead of [a]m . We have the following addition and multiplication table modulo m: + 0 1 2 3 4 0 0 1 2 3 4 1 1 2 3 4 0 2 2 3 4 0 1 3 3 4 0 1 2 · 0 1 2 3 4 4 4 0 1 2 3 0 0 0 0 0 0 1 0 1 2 3 4 2 0 2 4 1 3 3 0 3 1 4 2 4 0 4 3 2 1 2. The Chinese Remainder Theorem Theorem 3 (Chinese Remainder Theorem). Suppose that m and n are positive integers such that gcd(m, n) = 1. Suppose that a and b are integers. Then there is a unique integer c with 0 ≤ c < mn such that c ≡ a(mod m) and c ≡ b(mod n) Proof. We find can find integers x, y ∈ Z such that xm + yn = 1. Note that xm ≡ 1( mod n) and yn ≡ 1( mod m). Consider d = bxm + ayn. We can write d = qmn + c with 0 ≤ c < mn. Then c ≡ d ≡ ayn ≡ a(mod m) and c ≡ d ≡ bxm ≡ b(mod n). This shows the existance of c. Suppose that c0 is another integer with c0 ≡ a(modm), c ≡ b(modn) and 0 ≤ c0 < mn. Then c − c0 is divisible by m and by n. Because gcd(m, n) = 1, c − c0 is divisible by mn. Since |c − c0 | < mn we must have that c = c0 . The Chinese Remainder Theorem tells us that there is a 1–1 correspondence between elements of Zmn and Zm × Zn . Given [c]m there is a unique pair ([a]m , [b]m ) ∈ Zm × Zn with c ≡ a(modm) and c ≡ b(modn). And given a pair ([a]m , [b]n ) ∈ Zm × Zn , there is a unique [c]mn ∈ Zmn with c ≡ a(modm) and c ≡ b(modn). The previous theorem easily can be generalized as follows. Theorem 4. Suppose that m1 , m2 , . . . , mk are pairwise relatively prime positive integers (so gcd(mi , mj ) = 1 for i 6= j). Suppose that a1 , a2 , . . . , ak are integers. Then there is a unique integer c with 0 ≤ c < m1 m2 · · · mk such that c ≡ ai (mod mi ) for i = 1, 2, . . . , k. Example 5. Show that the difference of two consecutive prime numbers can be arbitrarily large. 2 We want to show that for every m there exists an n such that n + 1, n + 2, . . . , n + m are not prime. Let us assume that n + 1 is divisible by 2 and that n > 2. Then n + 1 is not a prime number. Now n + 2 is not divisible by 2. However, we could assume that n + 2 is divisible by 3 and n + 2 > 3. Then n + 2 is certainly not a prime either. Similarly we could assume that n + 3 is divisible by 5 and n + 3 > 5. The Chinese Remainder Theorem comes to the rescue. Proof. Let p1 , p2 , . . . , pm be the first m prime numbers. Using the Chinese Remainder theorem we can find an integer c such that n ≡ −i(modpi ) for i = 1, 2, . . . , m. Without loss of generality we may assume that n > pi for all i (otherwise we may add a multiple of p1 p2 · · · pm to n). For every i in {1, 2, . . . , m} we see that pi divides n + i but c + i > pi . This shows that c + i is not a prime number. A slightly easier proof is the following. Proof. For every n, consider the numbers n! + 2, n! + 3, · · · , n! + n. all these numbers are not prime numbers because n! + i is divisible by i. 3. The Theorems of Euler, Fermat and Wilson For an integer n we define φ(n) as the number of elements in the set {a ∈ Z | 1 ≤ a ≤ n, gcd(a, n) = 1} of all positive integers a which are relatively prime to n. Note that if a ≡ b( mod n) then gcd(a, n) = gcd(b, n). So the congruence class of a modulo n determines whether gcd(a, n) = 1. Let us call a congruence class [a]n reduced if gcd(a, n) = 1. The congruence classes modulo n are exactly {[1]n , [2]n , . . . , [n]n }. The reduced congruence classes are {[a]n mod 1 ≤ a ≤ n and gcd(a, n) = 1}. So there are exactly φ(n) reduced congruence classes modulo n. The set of reduced congruence classes is denoted by Z?n . Lemma 6. If m and n are positive integers then φ(mn) = φ(m)φ(n). Proof. Recall that, by the Chinese Remainder Theorem, we have a 1–1 correspondence between Zmn and Zm × Zn . Suppose that c ≡ a(modm) and c ≡ b(modn). If gcd(c, mn) = 1 then gcd(a, m) = gcd(b, n) = 1. Conversely, suppose that gcd(c, mn) 6= 1. Then there exists a prime p with p | c and p | mn. We have p | m or p min n. Suppose that p | m. Then p | a, so p is a common divisor of a and m and gcd(a, m) 6= 1. If p | n then we see that gcd(b, n) 6= 1 in a similar way. It follows that the 1–1 correspondence between Zmn and ? Zm × Zn induces a 1–1 correspondence between Zmn and Z?m × Z?n . So we have φ(mn) = |Z?mn | = |Z?m × Z?n | = φ(m)φ(n). 3 Lemma 7. If p is a prime number and k is a positive integer then φ(pk ) = (p − 1)pk−1 . Proof. The elements of {1, 2, 3, . . . , pk } that are not relatively prime to pk are exactly the pk−1 multiples of p. This shows that φ(pk ) = pk − pk−1 = (p − 1)pk−1 . In general if n = pa11 pa22 · · · pakk is the prime factorization of n, where p1 < p2 < · · · < pk are distinct prime numbers and a1 , a2 , . . . , ak are positive integers, then φ(n) = (p1 − 1)pa11 −1 (p2 − 1)pa22 −1 · · · (pk − 1)pakk −1 . Theorem 8 (Euler). If a ∈ Z and m is a positive integer with gcd(a, m) = 1, then we have aφ(m) ≡ 1(modm). Proof. Let b1 , b2 , . . . , bφ(m) be the reduced congruence classes modulo m. From gcd(a, m) = 1 and gcd(bi , m) = 1 follows that gcd(abi , m) = 1. So ab1 , ab2 , . . . , abφ(m) are also reduced congruences modulo m. Suppose that abi = abj . Then m divides abj −abi = a(bj − bi ). Since gcd(a, m) = 1, it follows that m | bj − bi , so bi = bj and i = j. This shows that ab1 , ab2 , . . . , abφ(m) are distinct, and therefore a permutation of b1 , b2 , . . . , bφ(m) . Taking the product gives b1 · b2 · · · bφ(m) = ab1 · ab2 · · · abφ(m) = aφ(m) b1 · b2 · · · bφ(m) It follows that m | b1 b2 . . . bφ(m) (aφ (m) − 1). Since gcd(bi , m) = 1 for all i, we have m | aφ(m) − 1. Theorem 9 (Fermat). If p is a prime and a ∈ Z then we have ap ≡ a(modp). Proof. If p 6| a, then gcd(p, a) = 1 and ap−1 ≡ 1(modp) by Euler’s theorem, because φ(p) = p − 1. It follows that ap ≡ a(modp). If p | a, then it is obvious that ap ≡ a(modp). Theorem 10 (Wilson). If p is a prime number then (p − 1)! ≡ −1(modp). 4 Proof. If a ∈ Z is not divisible by p, then gcd(a, p) = 1. So there exist integers x and y with ax + py = 1. It follows that ax ≡ 1(modp). One can also verify that x is unique modulo p: if ax0 ≡ 1(modp), then x ≡ x0 (modp). So every a with 1 ≤ a ≤ p − 1 has a unique partner b with 1 ≤ b ≤ p − 1 such that ab ≡ 1(modm). If a is his own partner, then a2 ≡ 1 mod p, and p | a2 − 1 = (a − 1)(a + 1). It follows that p | a + 1 or p | a − 1, so a = 1 or a = p − 1. So we can divide {2, 3, . . . , p − 2} up in pairs {2, 3, . . . , p − 2} = {x1 , y1 } ∪ {x2 , y2 } ∪ · · · ∪ {xr , yr } where r = (p − 3)/2, and xi yi ≡ 1(modp) for all i. It follows that (p − 1)! = (−1) · 1 · (x1 y1 ) · (x2 y2 ) · · · (xr yr ) ≡ (−1) · 1 · · · 1 = −1(modp). 4. Exercises Exercise 1 (Gardner, M., The Monkey and the Coconuts, Ch. 9 in The Second Scientific American Book of Puzzles & Diversions: A New Selection. New York: Simon and Schuster, pp. 104-111, 1961.). *** Five sailors survive a shipwreck and swim to a tiny island where there is nothing but a coconut tree and a monkey. The sailors gather all the coconuts and put them in a big pile under the tree. Exhausted, they agree to go to wait until the next morning to divide up the coconuts. At one o’clock in the morning, the first sailor wakes. He realizes that he can’t trust the others, and decides to take his share now. He divides the coconuts into five equal piles, but there is one left over. He gives that coconut to the monkey, buries his coconuts, and puts the rest of the coconuts back under the tree. At two o’clock, the second sailor wakes up. Not realizing that the first sailor has already taken his share, he too divides the coconuts up into five piles, leaving one over which he gives to the monkey. He then hides his share, and piles the remainder back under the tree. At three, four and five o’clock in the morning, the third, fourth and fifth sailors each wake up and carry out the same actions. In the morning, all the sailors wake up, and try to look innocent. No one makes a remark about the diminished pile of coconuts, and no one decides to be honest and admit that they’ve already taken their share. Instead, they divide the pile up into five piles, for the sixth time, and find that there is yet again one coconut left over, which they give to the monkey. How many coconuts were there originally? (Find the smallest number of coconuts that is consistent with this story.) Exercise 2. *** Show that an integer is divisible by 9 if and only if the sum of the digits is divisible by 9. For example, 342 and 3 + 4 + 2 = 9 are both divisible by 9. Also, show that an integer is divisible by 11 if and only if the alternating sum of the digits is divisible by 11. For example 9183 and 9 − 1 + 8 − 3 = 13 are both not divisible by 11. Exercise 3. ** Suppose that a is a positive integer not divisible by 2, 3 or 5. Show that there exists a positive integer b such that ab = 111 · · · 1. Exercise 4. *** Give an positive integer N such that the integer consisting of N 1’s is divisible by 119. 5 Exercise 5. ** Find a multiple of 2003 that ends with the digits 9999. Exercise 6. * Suppose that a, b, c are positive integer such that gcd(a, b) = 1. Show that one of the integers c + b, c + 2b, · · · , c + ab is divisible by a. 100 ) Exercise 7. ** The number googol is 10100 . The number googolplex is 10googol = 10(10 What is the remainder if we divide googolplex by 37? . Exercise 8. *** Show that every nonzero integer m divides infinitely many Fibonacci numbers. (Recall that the Fibonacci numbers are defined by F0 = F1 = 1, and Fn+1 = Fn + Fn−1 for n > 1.) Exercise 9. *** A positive integer is called square-free if it is not divisible by any square a2 with a ≥ 2. Show that there are arbitrary large gaps between 2 consecutive square-free integers. Exercise 10. *** Show that the equation a2 + b2 = 3c2 has no integer solutions except a = b = c = 0. Exercise 11. ** Suppose that p and q are primes and q divides 2p − 1. Show that p divides q − 1. Exercise 12. ***** There are N lights arranged in a circle, labeled 0, 1, . . . , N − 1 counterclockwise. In the beginning light 0 is on and all other lights are off. In the next round light i + 1 switches if light i was on in the previous round (take i modulo N : light 1 switches if light N − 1 is on in the previous round). For which N will be all lights be off eventually? And how many rounds will it take? Exercise 13. ***** Suppose that p is a prime ≥ 5. Let a and b be integers such that 1 a 1 1 + + ··· + = 1 2 p−1 b Prove that a is divisible by p2 . 6