Courses / Mathematics I
Arithmetic and Number Theory

GCD and the Euclidean Algorithm

The greatest common divisor (a, b) is the largest positive integer dividing both a and b.

Mathematics I 259 words Free to read

The greatest common divisor gcd(a,b)\gcd(a, b) is the largest positive integer dividing both aa and bb. Its partner, the least common multiple lcm(a,b)\operatorname{lcm}(a, b), is the smallest positive integer that both aa and bb divide.

Factoring is slow for large numbers. The Euclidean algorithm finds gcd(a,b)\gcd(a, b) instantly using the rule: gcd(a,b)=gcd(b,r)\gcd(a, b) = \gcd(b, r) where rr is the remainder of a÷ba \div b.

StepDivisionRemainder (rr)
148=218+1248 = 2 \cdot 18 + 121212
218=112+618 = 1 \cdot 12 + 666
312=26+012 = 2 \cdot 6 + 000

Repeatedly replace (a,b)(a, b) with (b,r)(b, r) until r=0r = 0. The last nonzero remainder is the gcd. Here, gcd(48,18)=6\gcd(48, 18) = 6.

The Euclidean step made physical: squares tiled out of a rectangle

Coprime and the LCM Link

Two numbers are coprime (relatively prime) when gcd(a,b)=1\gcd(a, b) = 1, meaning they share no prime factors. This is essential for finding multiplicative inverses in modular arithmetic.

You can find the lcm instantly without factoring using the identity: gcd(a,b)lcm(a,b)=ab\gcd(a, b) \cdot \operatorname{lcm}(a, b) = a \cdot b Rearranging gives lcm(a,b)=abgcd(a,b)\operatorname{lcm}(a, b) = \frac{ab}{\gcd(a,b)}.

Common Pitfall: Never confuse the two terms:

PropertyGCDLCM
MeaningDivisor of bothMultiple of both
BoundAt most the smallerAt least the larger
Examplegcd(12,18)=6\gcd(12, 18) = 6lcm(12,18)=36\operatorname{lcm}(12, 18) = 36

Practise this lesson

The explanation above is free to read. The graded practice for this lesson lives in the Tryals app.

10practice questions
2interactive scenes

Arithmetic and Number Theory