gcd - Euclidean algorithm and greatest common divisor So...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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

Page1 / 2

gcd - Euclidean algorithm and greatest common divisor So...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online