This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Euclidean algorithm and greatest common divisor So you have two positive integers, a and b , and you want to find d = gcd ( a, b ) and s, t such that as + bt = d . Well, heres how you do it. Suppose a b . Then, by the division algorithm, there are unique q 1 , r 1 such that a = q 1 b + r 1 . Well, unless r 1 is equal to 0, we arent done. Remember the division algorithm, were guaranteed that r 1 < b . So we can do the division algorithm on those two, so that b = q 2 r 1 + r 2 . Now we are guaranteed that r 2 < r 1 . If r 2 = 0, were done, and the gcd ( a, b ) = r 1 . Otherwise, we keep doing this (getting q i and r i until, at long last, r i = 0. Then the gcd ( a, b ) = r i- 1 , the previous remainder. But thats only half the battle. We need to find s, t such that as + bt = d . So heres what we do. Notice that the remainder in each equation is used in the next line as a divisor. So what we can do is solve each equation for r i . So, from the first equation, we get that....
View Full Document