How the Euclidean algorithm works
Euclid described this method in Book VII of the Elements, around 300 BC. It is still one of the fastest ways to find a GCD: the numbers at least halve every two steps.
Given two positive whole numbers and with :
- Find the quotient and remainder so that , where .
- If , stop: .
- Otherwise replace with and with , and repeat.
For more than two numbers, apply it in turn:
The LCM follows from the GCD:
Worked example: GCD of 48 and 180
These are the calculator's default numbers, so the result above matches each line here.
| Step | Division a = b × q + r | Remainder |
|---|---|---|
| Step 1 | 180 = 48 × 3 + 36 | 36 |
| Step 2 | 48 = 36 × 1 + 12 | 12 |
| Step 3 | 36 = 12 × 3 + 0 | 0 (stop) |
The last non-zero remainder is 12, so GCD(48, 180) = 12. The LCM is 48 × 180 ÷ 12 = 720.
Where the GCD is used
- Simplifying fractions: divide the top and bottom by their GCD. 48/180 becomes 4/15.
- Equal groups: the largest number of equal teams you can make from 48 boys and 180 girls, with no one left over, is the GCD: 12 teams.
- Tiling: the largest square tile that fits a 48 cm by 180 cm area exactly is 12 cm.
- Repeating events: two buses leaving every 48 and 180 minutes leave together again after the LCM, 720 minutes.