Greatest Common Divisor Calculator
Test cases replayed : 2 of 2 match · Methodology · No outside source listed
Enter two or three whole numbers to get their greatest common divisor (GCD) and their least common multiple (LCM).
Result
Greatest common divisor (GCD)
Least common multiple (LCM)
- First number ÷ GCD
- Second number ÷ GCD
Estimate for planning only, not tax, legal, financial or medical advice. This calculator uses the method explained on this page.
This browser did not allow copying. The sentence is in the box below, already selected: copy it with your keyboard or the menu.
How to use this calculator
Fill in the fields in this order; each step takes you to its field.
- First whole number: enter a number.
- Second whole number: enter a number.
- Third whole number (optional, 0 to leave out): enter a number.
- Read the result: Greatest common divisor (GCD); the panel also shows Least common multiple (LCM), First number ÷ GCD and Second number ÷ GCD.
How this calculator works
The GCD is found with Euclid's algorithm (Euclid's Elements, Book VII): replace the pair (a, b) by (b, a mod b) until the remainder is 0; the last non-zero number is the GCD. For three numbers, gcd(a, b, c) = gcd(gcd(a, b), c).
The least common multiple of two numbers is lcm(a, b) = |a × b| ÷ gcd(a, b); for three numbers it is applied step by step. Decimals are rounded to the nearest whole number first.
The formula
| Symbol | Meaning |
|---|---|
| First whole number | |
| Second whole number | |
| Third whole number (optional, 0 to leave out) | |
| Greatest common divisor (GCD) | |
gcd(a, b, …) | the greatest common divisor of the values. |
Worked example
| First whole number | 48 |
|---|---|
| Second whole number | 180 |
| Third whole number (optional, 0 to leave out) | 0 |
| Least common multiple (LCM) | 720 |
|---|---|
| First number ÷ GCD | 4 |
| Second number ÷ GCD | 15 |
Greatest common divisor (GCD) 12
Each step uses the unrounded value of the step before it; figures on this page are rounded for display.
Frequently asked questions
What is the GCD of 48 and 180?
12. Euclid's algorithm gives 180 mod 48 = 36, 48 mod 36 = 12, 36 mod 12 = 0, so the GCD is 12, and the LCM is 48 × 180 ÷ 12 = 720.
Is the GCD the same as the GCF?
Yes. Greatest common divisor, greatest common factor and highest common factor are three names for the same number.
What does a GCD of 1 mean?
The numbers are coprime (relatively prime): they share no factor other than 1.