Proof

We use three properties of the greatest common divisor:

gcd(a,b) = gcd(b,a)

gcd(a,b) = gcd(a,b - ka)

gcd(a,0) = a.

These properties imply that in each step of the algorithm the gcd is left invariant. The variable b decreases with each step. Eventually we come to the point that b equals 0. Then the algorithm ends and it will give gcd(a,0) = a as output.