Euclidean Algorithm for the GCD

The Euclidean algorithm hinges on the following lemma (recall that a lemma is a "little theorem"):

Lemma: Let a = bq + r where a, b, q and r are integers. Then gcd(a,b) = gcd(b,r).

Proof: Suppose d divides both a and b. Then d also divides abq = r and so d divides both b and r.

Now suppose that d divdes b and r. Then d also divides bq + r = a and so d divides both a and b.

Since all divisors of a and b are also divisors of b and r (and vice versa), we conclude that gcd(a,b) = gcd(b,r).