Free calculator

GCD and LCM Calculator — Greatest Common Divisor and Least Common Multiple

The greatest common divisor and least common multiple of up to six numbers, by prime factors and by the Euclidean algorithm.

The greatest common divisor (GCD) is the largest number that divides every number in the list; the least common multiple (LCM) is the smallest number that every one divides into. For 12, 18 and 30 the GCD is 6 and the LCM is 180. Both come from prime factorisation.

Try it now

Two to six whole numbers, separated by commas or spaces.

Updates as you type
GCD 6 LCM 180 GCD 6 is the largest number that divides all of them; LCM 180 is the smallest number all of them divide into.

Step by step

  1. Break each number into prime factors
    12 = 22 × 3
    18 = 2 × 32
    30 = 2 × 3 × 5
  2. GCD: take only the primes every number shares, each at its lowest power
    GCD = 2 × 3 = 6
  3. LCM: take every prime that appears, each at its highest power
    LCM = 22 × 32 × 5 = 180

Finding the GCD and LCM from prime factors

Write each number as a product of primes. 12 = 2² × 3, 18 = 2 × 3² and 30 = 2 × 3 × 5.

  • GCD: take only the primes that appear in every number, each at its lowest power. Here 2 and 3 are in all three; the lowest powers are 2¹ and 3¹, so GCD = 6.
  • LCM: take every prime that appears anywhere, each at its highest power: 2², 3² and 5, so LCM = 4 × 9 × 5 = 180.

The Euclidean algorithm, for big numbers

Factorising 48 and 180 is easy; factorising two ten-digit numbers is not. Euclid’s method avoids it: divide the larger by the smaller, then divide the smaller by the remainder, and repeat until the remainder is 0. The last non-zero remainder is the GCD. For 180 and 48: 180 = 3 × 48 + 36, 48 = 1 × 36 + 12, 36 = 3 × 12 + 0, so the GCD is 12.

For two numbers there is a shortcut for the other half: GCD × LCM = the product of the two numbers. Here 12 × 720 = 8640 = 48 × 180, so the LCM is 720.

Where you actually use them

The LCM of two denominators is the least common denominator, the number you need to add fractions: 1/4 + 1/6 uses the LCM of 4 and 6, which is 12, giving 3/12 + 2/12 = 5/12. The least common denominator guide walks through it.

The GCD is what you divide top and bottom by to simplify a fraction. 18/24 has GCD 6, so it simplifies to 3/4. The simplifying fractions guide covers that side.

Worked examples

Worked examples

Each one is computed by the calculator above, so the answers are the real output.

GCD and LCM of 12, 18 and 30

Three numbers: the primes common to all of them give the GCD.

GCD 6 LCM 180 GCD 6 is the largest number that divides all of them; LCM 180 is the smallest number all of them divide into.

Step by step

  1. Break each number into prime factors
    12 = 22 × 3
    18 = 2 × 32
    30 = 2 × 3 × 5
  2. GCD: take only the primes every number shares, each at its lowest power
    GCD = 2 × 3 = 6
  3. LCM: take every prime that appears, each at its highest power
    LCM = 22 × 32 × 5 = 180

GCD and LCM of 48 and 180

A pair, so the Euclidean algorithm is shown alongside the factorisation.

GCD 12 LCM 720 GCD 12 is the largest number that divides all of them; LCM 720 is the smallest number all of them divide into.

Step by step

  1. Break each number into prime factors
    48 = 24 × 3
    180 = 22 × 32 × 5
  2. GCD: take only the primes every number shares, each at its lowest power
    GCD = 22 × 3 = 12
  3. LCM: take every prime that appears, each at its highest power
    LCM = 24 × 32 × 5 = 720
  4. Check the GCD with the Euclidean algorithm: divide, then divide the divisor by the remainder
    DivideQuotientRemainder
    180 ÷ 48336
    48 ÷ 36112
    36 ÷ 1230
  5. The last non-zero remainder is the GCD
    GCD(180, 48) = 12

Also worth knowing

For two numbers, GCD × LCM equals their product
12 × 720 = 48 × 180 = 8640

GCD and LCM of 7 and 13

Two primes share nothing, so the GCD is 1 and the LCM is their product, 91.

GCD 1 LCM 91 The numbers are coprime — they share no factor except 1. GCD 1 is the largest number that divides all of them; LCM 91 is the smallest number all of them divide into.

Step by step

  1. Break each number into prime factors
    7 = 7
    13 = 13
  2. No prime is shared by every number, so the GCD is 1
    GCD = 1
  3. LCM: take every prime that appears, each at its highest power
    LCM = 7 × 13 = 91
  4. Check the GCD with the Euclidean algorithm: divide, then divide the divisor by the remainder
    DivideQuotientRemainder
    13 ÷ 716
    7 ÷ 611
    6 ÷ 160
  5. The last non-zero remainder is the GCD
    GCD(13, 7) = 1

Also worth knowing

For two numbers, GCD × LCM equals their product
1 × 91 = 7 × 13 = 91

FAQ

Questions people ask

What is the difference between GCD and LCM?

The GCD is the largest number that divides all the numbers; the LCM is the smallest number that all of them divide. The GCD is never larger than the smallest input, and the LCM is never smaller than the largest.

What is the GCD of two prime numbers?

It is 1, because two different primes share no factor other than 1. Numbers like that are called coprime, and their LCM is their product.

Is GCD the same as HCF?

Yes. Highest common factor (HCF) and greatest common divisor are two names for the same number.

How many numbers can I enter?

Between two and six whole numbers, separated by commas or spaces.

Related app: Fraction Calculator

This one lives on the website. The related app below covers the surrounding topic.

Free to download. AI explanations and dark mode are part of the optional PRO subscription.