* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Number Theory Learning Module 3 — The Greatest Common
Survey
Document related concepts
List of important publications in mathematics wikipedia , lookup
List of first-order theories wikipedia , lookup
Abuse of notation wikipedia , lookup
Mathematical proof wikipedia , lookup
Location arithmetic wikipedia , lookup
List of prime numbers wikipedia , lookup
Mathematics of radio engineering wikipedia , lookup
Factorization wikipedia , lookup
Quadratic reciprocity wikipedia , lookup
Collatz conjecture wikipedia , lookup
Factorization of polynomials over finite fields wikipedia , lookup
Transcript
Number Theory Learning Module 3 — The Greatest Common Divisor 1 1 Objectives. • Understand the definition of greatest common divisor (gcd). • Learn the basic the properties of the gcd. • Understand Euclid’s algorithm. • Learn basic proofing techniques for greatest common divisors. 2 The Greatest Common Divisor Classical Greek mathematics concerned itself mostly with geometry. The notion of measurement is fundamental to geometry, and the Greeks were the first to provide a formal foundation for this concept. Surprisingly, however, they never used fractions to express measurements (and never developed an arithmetic of fractions). They expressed geometrical measurements as relations between ratios. In numerical terms, these are statements like: 168 is to 120 as 7 is to 4, (2.1) which we would write today as 168{120 7{5. Statements such as (2.1) were natural to greek mathematicians because they viewed measuring as the process of finding a “common integral measure”. For example, we have: 168 24 7 120 24 5, so that we can use the integer 24 as a “common unit” to measure the numbers 168 and 120. Going back to our example, notice that 24 is not the only common integral measure for the integers 168 and 120, since we also have, for example, 168 6 28 and 120 6 20. The number 24, however, is the largest integer that can be used to “measure” both 168 and 120, and gives the representation in lowest terms for their ratio. This motivates the following definition: Definition 2.1. Let a and b be integers that are not both zero. Then, the greatest common divisor (gcd) of a and b is the largest integer that divides both a and b, and is denoted by gcdpa, bq. For example, the greatest common divisor of 168 and 120 is 24. Or, gcdp168, 120q 24. This can be verified from the definition by listing all positive divisors of 168 and 120: Divisors of 168 : 1, 2, 3, 4, 6, 7, 8, 12, 14, 21, 24, 28, 42, 56, 84, 168 Divisors of 120 : 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 24, 30, 40, 60, 120 We can see that 24 is the largest integer that is in both lists. An important observation is that the gcd of two integers is always positive. The gcd, however, is defined for negative integers as well. In fact, using the fact that the set of divisors of a and a are identical, it easy to see that for, all integers a, b: gcdpa, bq gcdpa, bq gcdpa, bq gcdp|a|, |b|q (2.2) We make the following convention when writing identities with gcds: we assume that all terms involved are welldefined. For example, in the expressions above, we are assuming that a and b are not both 0. Created by L. Felipe Martins. [email protected] License: http://creativecommons.org/licenses/by-nc-sa/3.0/us/ Number Theory Learning Module 3 — The Greatest Common Divisor 2 By the way, there is a subtle point about Definition 2.1. Whenever we talk about the largest integer satisfying a property, it is important to make sure the set of integers in question is bounded from above. In our case, however, everything is fine, since any divisor of a nonzero integer a less than or equal to |a|, so that the set of divisors of a is finite. Thus, if at least one of a and b are not zero, the set of common divisors is finite, and has a largest element. This brings the question of what happens when one of the integers a, b is zero. What is gcdpa, 0q, for a 0? Well, let’s use the definition. This is the largest integer that divides both a and 0. However, every integer divides zero, so gcdpa, 0q is simply the largest divisor of a, which is |a|. That is: gcdpa, 0q |a| if a 0. (2.3) The situation is different if both number are zero: then, the set of common divisors consists of all integers, and has no largest element. This is why the case a b 0 is explicitly excluded from Definition 2.1. Always remember this: gcdp0, 0q is not defined. The reader might find it silly to be talking so much about the special case of one of the terms in the gcd being 0. This little case turns out to be extremely important, as we will see in Section 3. Many facts about the gcd can be derived directly form the definition. Suppose that we want to show that gcdpa, bq gcdpc, d q. (2.4) (Whenever we write an expression with gcd’s, we assume that all terms are well-defined. Here, for example we assume ab 0 and cd 0.) One technique that we can use is the following: 1. Assume first that q is a common divisor of a and b. Show that q is a common divisor of c and d. 2. Then assume that q is a common divisor of c and d. Show that q is a common divisor of a and b. In other words, we prove that the set of common divisors of a and b is identical to the set of common divisors of c and d. This proving technique is illustrated in the following result. Theorem 2.2. Let a and b and n be integers. Then: gcdpa, bq gcdpa, a bq gcdpa b, bq (2.5) gcdpa, bq gcdpa, a bq gcdpa b, bq Also, if b 0: (2.6) gcdpa, bq gcdpa, na bq gcdpa nb, bq (2.7) gcdpa, bq gcdpb, a mod bq Proof. Let’s first show that gcdpa, bq gcdpa, a bq. Following the prescription above: 1. Let q be a common divisor of a and b. Then q divides a 2. Let q be a common divisor of a and a b. (2.8) b. So, q is a common divisor of a and a b. Then q divides pa b. bq a b, so that q is a common divisor of a and We could prove the other identities in (2.5) and (2.6) by the same method. However, it is faster to simply use what we have already learned. For example, we have: gcdpa, bq gcdpa, bq gcdpa, a pbqq gcdpa, a bq. Identity (2.7) is left for the reader to prove in the exercises. Finally, (2.8) follows from (2.7). If we let q a div b and r a mod b, then a qb r so that r a qb. Then gcdpb, a mod bq gcdpb, rq gcdpb, a qbq gcdpb, pa qbq qbq gcdpb, aq gcdpa, bq. Created by L. Felipe Martins. [email protected] License: http://creativecommons.org/licenses/by-nc-sa/3.0/us/ Number Theory Learning Module 3 — The Greatest Common Divisor 3 3 Euclid’s Algorithm One way to compute the gcd of two numbers is to use their prime factorization. For example, from: 46305 33 5 73 and 31500 22 32 53 7 we can conclude that gcdpa, bq 32 5 7 315. This is not, however, the most efficient way of computing the gcd for large numbers. A much better algorithm was discovered by the Euclid. The idea is to repeatedly use identity (2.8), reducing with each step the size of the numbers: gcdp46305, 31500q gcdp31500, 14805q gcdp14805, 1890q gcdp1890, 1575q gcdp1575, 315q gcdp315, 0q = gcdp31500, 46305 mod 31500q gcdp14805, 31500 mod 14805q gcdp1890, 14805 mod 1890q gcdp1575, 1890 mod 1575q gcdp315, 1575 mod 315q 315 We conclude that gcdp46305, 31500q 315. Notice that in the last line we used (2.3). (We warned that this special case would be important, remember?) The next result shows that the method works in general. Theorem 3.1 (Euclid’s algorithm). Let a, b be two integers, not both zero. The gcd of a and b can be found by the following algorithm: 1. Let r0 a and r1 b. 2. For n ¥ 1, while rn 0, let rn 1 rn1 mod rn . Then, gcdpa, bq |rn1 |, that is, the last nonzero remainder in the chain of calculations. Proof. We start by observing that, since rn 1 is the remainder of rn1 divided by rn , we have |rn no n such that rn 0, then we have generated an infinite decreasing sequence of positive integers: 1 | |rn |. If there is |r1 | ¡ |r2 | ¡ |r3 | ¡ . . . , which is impossible. We conclude that there must be a n such that rn 0. For this n we have, applying identity (2.8) repeatedly: gcdpa, bq gcdpr0 , r1 q gcdpr1 , r2 q gcdprn1 , rn q gcdprn1 , 0q |rn1 |, which finishes the proof. (Notice a subtle point: the only reason we take the absolute value of rn1 is to be correct if the algorithm stops in the very first step, in the case b 0 and a 0. An alternative is to let r0 |a|). Example 3.2. As another example, let’s compute gcdp1225, 351q. It is convenient to lay out the computations in a table. In each row, rn is the remainder of the division of the integers in the two previous rows. n 0 1 2 3 4 5 6 Created by L. Felipe Martins. [email protected] License: http://creativecommons.org/licenses/by-nc-sa/3.0/us/ xn 1225 351 172 7 4 3 1 Number Theory Learning Module 3 — The Greatest Common Divisor 4 Thus, gcdp1225, 351q 1. This means that 1225 and 351 have no common factor greater than 1. In this case, we say that 1225 and 351 are relatively prime. We will have more to say about relatively prime integers in the next learning module. 4 Problems 1. Prove the identities in (2.5), (2.6) and (2.7) that were not proved in the text. 2. Use Euclid’s algorithm to compute gcdpa, bq for each given pair of integers. (a) a 196, b 385 (b) a 1755, b 375 (c) a 9261, b 2499 (d) a 313807, b 601859 3. The Fibonacci sequence is defined as follows: F1 1, For example, F3 F2 F1 1 F2 1, 1 2, F4 F3 Fn Fn1 Fn2 if n ¡ 2. F2 2 (a) Compute F5 , F6 , F7 and F8 . (b) Use Euclid’s algorithm to compute gcdpFn , Fn 1 1 3, F4 F3 F2 3 25 q for n 4, 5, 6, 7. (c) What can you observe from this calculation? Write a mathematical conjecture based in your observations. (d) Prove your conjecture. 4. The method of computing the gcd using prime factorizations can be formalized as follows: Suppose that a and b have the prime factorizations: a pr11 pr22 . . . prnn b ps11 ps22 . . . psnn (Zero exponents are allowed here.) Show that: gcdpa, bq pt11 pt22 . . . ptnn , where ti mintri , si u, that is, ti is the large of the two integers ri , si . 5. Determine if each of the statements below are true or false, providing a proof or counterexample according to each case. In each statement, assume that variables represent arbitrary integers for which all gcds are well defined. (a) gcdpa, bq gcdpa b, a bq (b) gcdpgcdpa, bq, cq gcdpa, gcdpb, cqq. (c) gcdpan , bn q gcdpa, bqn , where n is a positive integer. (d) gcdpac, bcq |c| gcdpa, bq. Created by L. Felipe Martins. [email protected] License: http://creativecommons.org/licenses/by-nc-sa/3.0/us/ Number Theory Learning Module 3 — The Greatest Common Divisor (e) a and a 5 1 are always relatively prime. (f) If p is prime, a and a p are always relatively prime. 6. Show that, if p is prime, then for any integer a we have: gcdp p, aq # p 1 if p divides a; otherwise 7. This problem presents yet another proof that there are infinitely many primes. (a) Let p1 , p2 , . . . , pn be prime numbers and k1 , k2 , . . . kn be arbitrary positive integers. What is the number of integers of the form: pe11 pe22 . . . penn with ei ¤ ki for i 1, 2, . . . , n. (b) Let M be an integer strictly larger than the number you computed in the previous item. Show that there is a prime number in r2, M s that is distinct of all pi for i 1, 2, . . . , n. Explain why this implies that there are infinitely many primes. 8. In this problem, we will explore an alternative algorithm for computation of the gcd, called the binary gcd algorithm. Suppose that a and b are nonnegative integers, not both 0. Then, to compute gcdpa, bq, proceed as follows. (a) Let m 1 (b) While b 0, do: i. If a b, exchange the values of a and b. ii. Then, select one of the following actions: A. If a and b are both even, then replace a by a{2, b by b{2 and multiply m by 2. B. If a is even and b is odd, then, replace a by a{2. C. If a is odd and b is even, then replace b by b{2. D. If a and b are both odd, replace a by pa bq{2. (c) When you reach a point where b 0, then ma is the gcd of the two initial numbers.. Do the following: (a) Use this algorithm to compute the gcd of the pairs of numbers given in Problem 2. (b) Prove that the algorithm always finishes and does indeed compute the gcdpa, bq. Created by L. Felipe Martins. [email protected] License: http://creativecommons.org/licenses/by-nc-sa/3.0/us/