Skip to content
FiftyCalc Free calculators for all 50 states

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

Sample figures

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.

Greatest Common Divisor Calculator

First whole number: enter a number. Prefilled example: 48.

Second whole number: enter a number. Prefilled example: 180.

Third whole number (optional, 0 to leave out): enter a number. Prefilled example: 0.

How to use this calculator

Fill in the fields in this order; each step takes you to its field.

  1. First whole number: enter a number.
  2. Second whole number: enter a number.
  3. Third whole number (optional, 0 to leave out): enter a number.
  4. 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

  1. G=gcd⁡(a,b,c)
Symbols used in the formula
SymbolMeaning
aFirst whole number
bSecond whole number
cThird whole number (optional, 0 to leave out)
GGreatest common divisor (GCD)
gcd(a, b, …)the greatest common divisor of the values.

Worked example

First whole number48
Second whole number180
Third whole number (optional, 0 to leave out)0
Least common multiple (LCM)720
First number ÷ GCD4
Second number ÷ GCD15
  1. G=gcd⁡(48,180,0)=12

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.

Related calculators