Divisibility Euclid s algorithm The following is an informal description of Euclid s algorithm for finding the greatest common divisor of a pair of numbers: Divide the smaller number into the larger, and note the remainder. Divide the remainder into the previous divisor, and note the remainder. Keep doing this until you get a remainder of 0. The last remainder you got right before the zero remainder is your GCF. See if the instructions make sense - try an example, then we ll back up and go through all the theory. Example: Use Euclid s algorithm to find gcd(300, 70). Now, the theory. We need to build this up in stages, and so we ll start with an observation. Let a and b be the two numbers in the previous example: a = 300 and b = 70. Let s and t be a various integers, and consider the quantity sa + tb for each of the pairs s and t. Note that s and t are chosen almost at random, but all choices are such that sa + tb > 0. What can you observe?
Theorem: Let a and b be integers, not both equal to 0. Then gcd(a, b) isthe smallest positive integer that can be expressed as a sum ma + nb, where m and n are also integers. The set is bounded below, since sa + tb > 0. [Nicodemi, p. 16] The Well-Ordering Principle says the set must have a smallest member; call it d. Anything that divides both a and b will also divide d. And d divides both a and b. So d must equal gcd(a, b). Corollary: An integer x is of the form ma + nb, withm, n Z, if and only if x is a multiple of gcd(a, b). [Nicodemi, p. 17] This corollary tells us whether an equation ma + nb = x with a, b, andx given will have integer solutions for m and n. Example: Will the equation 25m +70n = 15 have integer solutions for m and n? Will the equation 25m +70n = 7 have integer solutions for m and n?
Relatively prime Let a and b be integers, not both zero. We say that a and b are relatively prime if gcd(a, b) =1. Example: Which pairs of numbers are relatively prime? 5and7 9and15 9and35 Proposition: Suppose that gcd(a, b) =d. Thengcd ³ a, b d d =1. For convenience in writing, let gcd(a, b) = d. By definition, d a and d b (it s a divisor of both). This means a d and b d are both integers. Also, by the previous theorem, d = ma + nb for some integers m and n. Divide everybody through by d: d d = ma d So 1 = m ³ a d + n µ bd. + nb d. You aren t going to find a postive integer smaller than 1, so 1 is the smallest positive integer that can be expressed as m ³ µ a + n bd. d And by that previous theorem, that makes 1 = gcd ³ a,. b d d
Euclid s lemma Suppose that gcd(a, b) = 1 and that a bc. Then a c. Euclid s lemma says that if you have two numbers a and b with no factors in common (other than 1), and you know that a divides some number that does have b has a factor...then that number a must be a factor of c, because it certainly can t be a factor of b. Suppose that gcd(a, b) = 1 and that a bc. By previous theorem, there exists integers m and n such that 1 = ma + nb. Multiply through by c: c = mac + nbc a mac (it appears there as a factor). The hypothesis is that a bc, so a nbc. Since a divides both mac and nbc, it divides their sum: a (mac + nbc) Which is equal to c: a c.
Euclid s algorithm Almost there - a couple more propositions, and we ll have an explanation of why Euclid s algorithm works. Proposition: If a>0 and a b, then gcd(a, b) = a. Proposition: Let a and b be integers and suppose that a = qb + r. Then gcd(a, b) = gcd(b, r). This is a classic use of the show two sets are equal by showing each is the subset of the other technique. The idea is to consider the set of common divisors of a and b, and the set of common divisors of b and r, and show that they are the same set (and therefore have the same largest element). Let S be the set of common divisors of a and b. LetT be the set of common divisors of b and r. Note a = qb + r, and therefore r = a qb. Show S T : Suppose x S. Then x a and x b. Therefore, x (a qb), and so x r (if x is a divisor of a and b, then it is also a divisor of r). Therefore x T, and S T. Show T S: Suppose x T. Then x b and x r. Therefore, x (bq + r), and so x a (if x is a divisor of b and r, thenx is a divisor of a). Therefore x S, and T S. So S = T, and the largest element of S must be the largest element of T. gcd(a, b) =gcd(b, r).
Example: Take the values a = 300 and b = 70. According to the previous proposition, what can you claim? The fact that this process can be repeated gives us Euclid s algorithm. Recall the original example: 300 = 4 70 + 20. gcd(300, 70) = gcd(70, 20). 70 = 3 20 + 10. gcd(70, 20)=gcd(20, 10). 20 = 2 10. And gcd(20, 10) = 10, since 10 20. gcd(300, 70) = gcd(70, 20) = gcd(20, 10) = 10