The Euclidean Algorithm
Start with two numbers

and

.
Here are the steps in the Euclidean Algorithm for finding

.
Divide

by

and take the remainder:

(We take

,

).
If the remainder is

stop.
If the remainder isn't

,
divide it into the last thing you divided by, and take the new remainder, then
go to step 2.

the
last non-zero remainder

,

.
Here are the steps:

Since

is the last non-zero remainder,

.
If

then

Prove this by showing that anything that divides

and

must divide

and

,
and anything that divides

and

must divide

and

.
Thus

is a divisor of

and

,
so can't be bigger than

:

.
Similarly,

.
Thus, they are equal. (When you write this up, supply the reasons for each
step.)
Here is what the Euclidean Algorithm looks like symbolically:

Thus,

since

is the last non-zero remainder.
Use the lemma to show that each

for all

.
Conclude that

.
Not only does the Euclidean Algorithm enable us to find the greatest common
divisor of two numbers, but it tells us how to express this GCD as a linear
combination of the two numbers. To see how this works, let's go back to the
first example of

:

Using the second equation:

.
Using the first equation, we can substitute for


Thus, we have expressed

(
)
as a linear combination of

and

Use the Euclidean algorithm to find

,
and express is as a linear combination of

and

.
Use the Euclidean algorithm to find

,
and express is as a linear combination of

and

.
Use the symbolic form of the Euclidean algorithm (see above) to explain why
you can always express

as a linear combination of

and

.
If you have trouble with the subscripts and the general argument, try it for,
say,

:

Write

as a linear combination of

and

.
(You only need to use the first three equations.)
(If you had similar trouble with Exercises 1 -- 3, do them just for the case

.
You'll need all three equations, since the last one will give you the
divisibility.)
The gcd(a,b) command in Matlab can actually be used to find the
GCD of

and

as a linear combination: you have to write it in a special way. Here's how it
looks:
>> [d,x,y]=gcd(24,14)
d =
2
x =
3
y =
-5
This shows that the

,
the

,
is

,
and can be written as

.