MathLabs
TheoremProved

Invariance and termination of the Euclidean algorithm

Statement

For integers a≥b>0a\ge b>0 with a=bq+r, 0≤r<ba=bq+r,\ 0\le r<b, the set of common divisors of aa and bb equals the set of common divisors of bb and rr; hence gcd⁡(a,b)=gcd⁡(b,r)\gcd(a,b)=\gcd(b,r), and repeating the division step terminates in finitely many steps with the last nonzero remainder equal to gcd⁡(a,b)\gcd(a,b).

Why is it true?

Subtracting a multiple of bb from aa cannot create or destroy a shared divisor with bb: anything that measures both aa and bb must also measure the leftover r=a−bqr=a-bq, and vice versa.

Proof sketch

Step 1 (Same common divisors). Let dd be any integer dividing both aa and bb, so a=dxa=dx and b=dyb=dy for integers x,yx,y. Then r=a−bq=dx−dyq=d(x−yq)r=a-bq=dx-dyq=d(x-yq), so d∣rd\mid r, meaning dd divides both bb and rr. Conversely, if dd divides both bb and rr, say b=dyb=dy and r=dzr=dz, then a=bq+r=dyq+dz=d(yq+z)a=bq+r=dyq+dz=d(yq+z), so d∣ad\mid a, meaning dd divides both aa and bb.

Step 2 (Equality of greatest common divisors). Because the pairs (a,b)(a,b) and (b,r)(b,r) have the exact same set of common divisors, they have the exact same maximum element: gcd⁡(a,b)=gcd⁡(b,r)\gcd(a,b)=\gcd(b,r).

Step 3 (Finite termination). Each division step produces a remainder satisfying 0≤r<b0\le r<b, so the sequence of second entries b>r1>r2>⋯≥0b > r_1 > r_2 > \cdots \ge 0 is a strictly decreasing sequence of non-negative integers. Such a sequence can have at most bb steps before reaching 00; at the step gcd⁡(rk−1,rk)=gcd⁡(rk,0)=rk\gcd(r_{k-1},r_k)=\gcd(r_k,0)=r_k, the last nonzero remainder rkr_k is gcd⁡(a,b)\gcd(a,b).

Topics that use this theorem

Step-by-step proofs

No step-by-step proof yet for this theorem.

References

  1. David M. Burton (2010). Elementary Number Theory
  2. John H. Conway, Richard K. Guy (1996). The Book of Numbers · DOI:10.1007/978-1-4612-4072-3