GCD and LCM calculator
Enter your whole numbers: the GCD (greatest common divisor, also called GCF) and the LCM (least common multiple) show, with the prime factorization and Euclid's steps.
- Checked on thousands of cases
- Updated November 7, 2026
Separated by spaces or commas, for example 12, 18, 30.
GCD
LCM
Prime factorization
- 12 = 2² × 3
- 18 = 2 × 3²
Euclid's algorithm
- 18 = 1 × 12 + 6
- 12 = 2 × 6 + 0
Quick challenge
Streak 0Best 0
Test yourself: every answer is computed by the tool, and the wrong choices are the most common traps.
How it works
Formula: LCM(a, b) = a × b ÷ GCD(a, b)
The GCD is the largest number that divides all your numbers; the LCM is the smallest number they all divide. Euclid's algorithm finds the GCD by repeated division: divide the larger by the smaller, then the divisor by the remainder, until the remainder is zero. For two numbers, GCD × LCM = a × b. The prime factorization shows why: the GCD takes the shared factors, the LCM all of them.
Worked examples
GCD and LCM of 12 and 18
GCD 6, LCM 36: 12 = 2² × 3 and 18 = 2 × 3².
Simplifying the fraction 84/126
The GCD of 84 and 126 is 42: the fraction becomes 2/3.
Two buses, every 12 and 20 minutes
They come together every 60 minutes: that's the LCM.
Common mistakes
Mixing up GCD and LCM.
The GCD divides every number, so it is smaller; the LCM is a multiple of all of them, so it is larger.
Taking the product as the LCM: 12 × 18 = 216.
The LCM of 12 and 18 is 36: divide the product by the GCD.
Thinking the GCD of 8 and 15 is 0.
It is 1: these numbers are coprime.
GCD and LCM of common pairs
| Numbers | GCD | LCM |
|---|---|---|
| 6, 8 | 2 | 24 |
| 8, 12 | 4 | 24 |
| 9, 12 | 3 | 36 |
| 12, 18 | 6 | 36 |
| 14, 21 | 7 | 42 |
| 15, 25 | 5 | 75 |
| 16, 24 | 8 | 48 |
| 18, 24 | 6 | 72 |
| 20, 30 | 10 | 60 |
| 24, 36 | 12 | 72 |
| 36, 48 | 12 | 144 |
| 45, 60 | 15 | 180 |
Frequently asked questions
How do you find the GCD?
With Euclid's algorithm: 18 = 1 × 12 + 6, then 12 = 2 × 6 + 0. The last non-zero remainder, 6, is the GCD.
How are GCD and LCM related?
For two numbers, their product equals GCD × LCM: 12 × 18 = 6 × 36.
How many numbers can I enter?
From 2 to 10 whole numbers, from 1 to 1 billion.
Math calculators
Math calculatorsOther calculators
- Dates & timeAge, days between dates
- HealthBMI, BMR, calories, running pace
- CookingBread dough, cups to grams, servings
- Home & DIYConcrete, paint, floors, walls, garden
- EverydayFuel cost, unit price, grades
- WeatherWind chill, heat index, storms
- MoneySales, tips, salary
- TechColors, passwords, binary…
- Random & gamesCoin flip, dice, name picker