Skip to content
Infinitesimal Dynamics home
Notebook: 0 XP

Number Theory / Divisibility

GCD and the Euclidean Algorithm

The fastest ancient algorithm still in daily use, and Bézout’s identity, which it proves for free.

3 min read · 2 sections · 2 checks

Contents 3 sections
  1. §1Remainders all the way down
  2. §2Bézout’s identity
  3. ?Check yourself

By the end you can

  • Compute greatest common divisors with the Euclidean algorithm
  • Run the extended algorithm to find Bézout coefficients
  • Solve linear Diophantine equations

Helps to know: Primes and Divisibility

§1Remainders all the way down

The key fact: gcd⁡(a,b)=gcd⁡(b,a mod b)\gcd(a, b) = \gcd(b, a \bmod b), because anything dividing aa and bb also divides the remainder. Repeat until the remainder is zero.

Example 1gcd⁡(252,198)\gcd(252, 198)

  1. 252=1⋅198+54252 = 1 \cdot 198 + 54

§2Bézout’s identity

Consequently ax+by=cax + by = c has integer solutions exactly when gcd⁡(a,b)∣c\gcd(a, b) \mid c. With jugs holding 4 and 6 litres you can measure only even amounts; with 4 and 7 you can measure any whole number.

Check yourself

  1. Q1
    gcd⁡(48,18)=\gcd(48, 18) =
  2. Q2
    Does 6x+9y=76x + 9y = 7 have integer solutions?