Maths WorkshopMaths problems with full solutions
Exercise 747Number theory › Divisibility and gcdL1Added 2 Nov 2026

Why the Euclidean algorithm works

#Euclidean algorithm#proof#division

Statement

Let a=bq+ra=bq+r with 0≤r<b0\le r<b. Prove that \divisibility(a,b)=\divisibility(b,r)\divisibility(a,b)=\divisibility(b,r).

Hint

Show that the set of common divisors of (a,b)(a,b) equals the set of common divisors of (b,r)(b,r).

Show solutionHide solution

Solution

Inclusion 1. If d∣ad\mid a and d∣bd\mid b, then d∣a−bq=rd\mid a-bq=r. So dd is a common divisor of bb and rr.

Inclusion 2. If d∣bd\mid b and d∣rd\mid r, then d∣bq+r=ad\mid bq+r=a. So dd is a common divisor of aa and bb.

Conclusion. The two pairs have the same common divisors, hence the same greatest one. The Euclidean algorithm terminates because the remainders strictly decrease: r<br<b, and each new remainder is strictly smaller than the previous one. It stops when the remainder is 00, and the last nonzero remainder is the divisibility.