We use three properties of the greatest common divisor:
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.