s5_2 - 2. INTEGERS AND ALGORITHMS 155 2. Integers and...

This preview shows pages 1–3. Sign up to view the full content.

2. INTEGERS AND ALGORITHMS 155 2. Integers and Algorithms 2.1. Euclidean Algorithm. Euclidean Algorithm. Suppose a and b are in- tegers with a b > 0. (1) Apply the division algorithm: a = bq + r , 0 r < b . (2) Rename b as a and r as b and repeat until r = 0. The last nonzero remainder is the greatest common divisor of a and b . The Euclidean Algorithm depends upon the following lemma. Lemma 2.1.1 . If a = bq + r , then GCD( a,b ) = GCD( b,r ) . Proof. We will show that if a = bq + r , then an integer d is a common divisor of a and b if, and only if, d is a common divisor of b and r . Let d be a common divisor of a and b . Then d | a and d | b . Thus d | ( a - bq ), which means d | r , since r = a - bq . Thus d is a common divisor of b and r . Now suppose d is a common divisor of b and r . Then d | b and d | r . Thus d | ( bq + r ), so d | a . Therefore, d must be a common divisor of a and b . Thus, the set of common divisors of a and b are the same as the set of common divisors of b and r . It follows that d is the greatest common divisor of a and b if and only if d is the greatest common divisor of b and r . ± Discussion The fact that the Euclidean algorithm actually gives the greatest common divi- sor of two integers follows from the division algorithm and the equality in Lemma 2.1.1. Applying the division algorithm repeatedly as indicated yields a sequence of remainders r 1 > r 2 > ··· > r n > 0 = r n +1 , where r 1 < b . Lemma 2.1.1 says that GCD( a,b ) = GCD( b,r 1 ) = GCD( r 1 ,r 2 ) = ··· = GCD( r n - 1 ,r n ) . But, since r n +1 = 0, r n divides r n - 1 , so that GCD( r n - 1 ,r n ) = r n . Thus, the last nonzero remainder is the greatest common divisor of a and b . Example 2.1.1 . Find GCD (1317, 56).

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2. INTEGERS AND ALGORITHMS 156 1317 = 56(23) + 29 56 = 29(1) + 27 29 = 27(1) + 2 27 = 2(13) + 1 2 = 1(2) + 0 GCD (1317,56)=1 Example 2.1.1 shows how to apply the Euclidean algorithm. Notice that when you proceed from one step to the next you make the new dividend the old divisor (replace a with b ) and the new divisor becomes the old remainder (replace b with r ). Recall that you can ﬁnd the quotient q by dividing b into a on your calculator and rounding down to the nearest integer. (That is, q = b a/b c .) You can then solve for r . Alternatively, if your calculator has a mod operation, then r = mod ( a,b ) and q = ( a - r ) /b . Since you only need to know the remainders to ﬁnd the greatest common divisor, you can proceed to ﬁnd them recursively as follows: Basis. r 1 = a mod b , r 2 = b mod r 1 . Recursion. r k +1 = r k - 1 mod r k , for k 2. (Continue until r n +1 = 0 for some n . ) 2.2. GCD ’s and Linear Combinations. Theorem
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/27/2011 for the course MCH 108 taught by Professor Penelopekirby during the Fall '08 term at FSU.

Page1 / 8

s5_2 - 2. INTEGERS AND ALGORITHMS 155 2. Integers and...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online