Why take the last non zero remainder in Euclid's algorithm as GCD?

690 Views Asked by At

So, I do understand why Euclid's algorithm works, it is pretty simple. $$\text{gcd}(a,b) \overset{!}{=} \text{gcd}(b,r) \iff a = cb + r$$

This is because:

$$a = cb + r \land\text{gcd}(a, b) = d \implies d|a \land d|b \implies d|(a-cb) \implies d|r$$ because $r = a -cb$

$$a = cb + r \land\text{gcd}(b, r) = d \implies d|b \land d|r \implies d|(cb+r) \implies d|a$$ because $a = cb+r$

But from this proof I do not see why the last non-zero remainder that comes from a repeated application of the above is actually the GCD. Am I overlooking something or does this proof not in fact tell so?

For example in this sequence, where does it tell in the proof to stop at $\text{gcd}(28,8)$?

$$\begin{align*} & \gcd(28, 64) = d\\ & 64 = 28(2) + 8 && \implies \gcd(28, 64) = \gcd(28, 8)\\ & 28 = 8(3) + 4 && \implies \gcd(28, 8) = \gcd(8, 4)\\ & 8 = 4(2) + 0 && \implies d = 4\\ \end{align*} $$