Calculator Tools

GCD and LCM: Euclid’s 2,300-year-old shortcut, and when two buses meet again

The greatest common divisor simplifies fractions, and the least common multiple tells you when repeating things line up again. This guide shows how to find both by hand, why Euclid’s method is so fast, and the one identity that links them.

By the Toolcloak team8 October 20264 min read
In this article
  1. Divisors you can see
  2. Method 1: prime factors
  3. Method 2: Euclid’s algorithm
  4. The GCD in action: simplifying fractions
  5. The LCM in action: when things line up again
  6. Quick practice

Two small ideas hide behind most fraction homework and a surprising amount of real scheduling. The greatest common divisor (GCD, also called HCF) is the biggest number that divides two numbers exactly. The least common multiple (LCM) is the smallest number that both of them divide into. One tells you how to shrink, the other how to align.

Divisors you can see

A divisor of a number divides it with no remainder. The divisors of 48 are 1, 2, 3, 4, 6, 8, 12, 16, 24 and 48. The divisors of 18 are 1, 2, 3, 6, 9 and 18. The ones that appear in both lists are the common divisors: 1, 2, 3 and 6. The largest of them, 6, is the GCD.

Divisors of 48 and 18, and what they share
Divisors of 48
10
Divisors of 18
6
Common divisors
4 (1, 2, 3, 6)

Listing divisors works for small numbers, but it gets slow quickly. The next two methods do not need long lists.

GCD as a tiling: a 48 × 18 rectangle in 6 × 6 squares
  • Squares of side 68 across × 3 down = 24

The GCD is the side of the largest square that tiles a rectangle exactly. A 48 × 18 floor needs 24 square tiles of side 6.

Enter two or more numbers and get the GCD, LCM and the working.Open GCD & LCM Calculator

Method 1: prime factors

Break each number into primes. 48 = 2⁴ × 3 and 18 = 2 × 3². For the GCD take the smaller power of each prime that both have. For the LCM take the larger power of every prime that appears.

PrimeIn 48In 18GCD uses (smaller)LCM uses (larger)
22⁴2¹2¹ = 22⁴ = 16
33¹3²3¹ = 33² = 9
Product2 × 3 = 616 × 9 = 144

The smaller powers give the GCD (6) and the larger powers give the LCM (144).

Method 2: Euclid’s algorithm

Written around 300 BC in Euclid’s Elements, this is one of the oldest algorithms still in everyday use. The idea: any number that divides both a and b also divides the remainder of a ÷ b. So replace the pair (a, b) by the smaller pair (b, remainder), and repeat until the remainder is zero. The last non-zero number is the GCD.

GCD of 1071 and 462
  1. 11071 = 2 × 462 + 147Remainder 147, so now find GCD(462, 147).
  2. 2462 = 3 × 147 + 21Remainder 21, so now find GCD(147, 21).
  3. 3147 = 7 × 21 + 0Remainder 0. The last non-zero number, 21, is the GCD.
Euclid shrinks the numbers fast (pair sizes)
1,071
Start: 1071
→ 462
Next big number
→ 147
Then
→ 21
Then

Each step replaces the bigger number by a much smaller remainder: 1071 → 462 → 147 → 21. Three divisions are enough.

How few steps Euclid needs
7GCD(123456, 7890)Six-digit numbers, a handful of divisions
2GCD(1000000, 999999)Neighbours finish at once
28GCD of two Fibonacci numbersThe slowest possible case

The worst cases are consecutive Fibonacci numbers, as proved by Gabriel Lamé in 1844. Even then, the step count grows with the number of digits, not the size of the numbers.

See the Fibonacci article for why those numbers are the slowest: each remainder is exactly the previous Fibonacci number, so the sequence shrinks as slowly as it can.

The GCD in action: simplifying fractions

To reduce a fraction to its simplest form, divide the top and bottom by their GCD. For 48/18 the GCD is 6, so 48 ÷ 6 = 8 and 18 ÷ 6 = 3, giving 8/3. Using the GCD guarantees the answer is fully reduced in one step; dividing by 2 and then by 3 would take two.

Reducing 48/18
Guessing small factors2 steps
  • 48/18 → 24/9
  • 24/9 → 8/3
  • Easy to stop too early
Divide by the GCD1 step
  • GCD(48, 18) = 6
  • 48 ÷ 6 = 8, 18 ÷ 6 = 3
  • Always fully simplified

Both reach 8/3. The GCD makes sure you never stop one step short.

The LCM in action: when things line up again

Two buses leave a stop together. One returns every 12 minutes, the other every 18. They next leave together at the LCM of 12 and 18, which is 36 minutes. The same idea schedules shifts, mixed repeating tasks and gear teeth that must return to the same pairing.

Bus A (every 12 min) and bus B (every 18 min)
  1. 0 min
    Both leave togetherThe starting point.
  2. 12 min
    Bus A againBus B is still on its way.
  3. 18 min
    Bus B againBus A is waiting for its next trip.
  4. 24 min
    Bus A againStill not together.
  5. 36 min
    Both leave togetherLCM(12, 18) = 36. The pattern repeats from here.
LCM of different pairs: smaller cycles meet sooner
4 and 6
12
6 and 10
30
12 and 18
36
8 and 15
120
7 and 13
91

When the two numbers share no common factor (7 and 13), the LCM is simply their product, 91. The more they share, the sooner they meet.

Quick practice

  1. GCD of 84 and 36? 84 = 2 × 36 + 12, 36 = 3 × 12, so 12.
  2. LCM of 84 and 36? 84 × 36 ÷ 12 = 252.
  3. Simplify 84/36. Divide both by 12 to get 7/3.
  4. Are 35 and 64 coprime? GCD(35, 64) = 1, so yes. Their LCM is 2,240.

Two numbers with GCD 1 are called coprime. Coprime numbers matter in encryption, where choosing keys depends on them. Read about it in prime numbers and RSA.

Questions people ask

What is the GCD of 48 and 18?

6. It is the largest number that divides both 48 and 18 exactly.

Are GCD and HCF the same thing?

Yes. HCF (highest common factor) and GCD (greatest common divisor) are different names for the same number.

How do you find the LCM from the GCD?

LCM(a, b) = a × b ÷ GCD(a, b). For 48 and 18 that is 864 ÷ 6 = 144.

What is the Euclidean algorithm?

A method that replaces (a, b) with (b, a mod b) over and over until the remainder is 0. The last non-zero value is the GCD.

What if the GCD is 1?

Then the numbers are coprime (relatively prime). Their LCM is just their product.

Where is the LCM used in everyday life?

Adding fractions with different denominators, scheduling repeating events, and gear or rotation problems all use the LCM.