Euclidean Algorithm for the GCD

Find gcd(36,22).

a=b*q+r
36=22*1+14
22=14*1+8
14=8*1+6
8=6*1+2
6=2*3+0

The last nonzero remainder (2 in this case) is the GCD. Actually it is the GCD of 6 and 8, but by the lemma it is also the GCD of 36 and 22.