LCM and GCF Calculator

Find the least common multiple and greatest common factor (HCF, GCD) of two or more numbers, with the method.

3 numbers

Separate numbers with commas, spaces or new lines. A comma always separates, so write 1234, not 1,234.

Least common multiple (LCM)

180

Greatest common factor (GCF, HCF or GCD)

6

Working by

Divide by the smallest prime that goes into any of the numbers, bringing down the ones it does not divide, until every number is 1.

2*121830
26915
3*3915
3135
5115
111
  1. Multiply all the divisors for the LCM.
    2 × 2 × 3 × 3 × 5 = 180
  2. Multiply the divisors marked *, which went into every number of their row, for the GCF.
    2 × 3 = 6

Enter two or more whole numbers to get their least common multiple and their greatest common factor together: for 12, 18, 30, an LCM of 180 and a GCF of 6. The working is shown by the method you were taught, with your own numbers.

The greatest common factor goes by three names. GCF, HCF (highest common factor, the usual name in India and the UK) and GCD (greatest common divisor) are the same number.

How to use it

Numbers takes 2 to 20 whole numbers of up to 30 digits each, separated by commas, spaces or new lines. A comma always separates, so write 1234, not 1,234. Signs are ignored: the results are for the absolute values.

Working by chooses the method shown under the results, and is remembered on your device:

  • Division — the ladder that divides all the numbers at once by primes, drawn for up to 40 divisions.
  • Prime factors — each number as a product of primes, then the highest and lowest powers.
  • Euclid — repeated division, two numbers at a time.
  • Listing — the multiples and factors of each number written out, when the LCM is 200 or less.

The results themselves always come from Euclid’s algorithm, which is immediate at any size. The first two methods need every number factored into primes; if that takes more than 2 seconds, which can happen with very large numbers, they are left out. Everything runs in your browser.

How it works

Common division. Write the numbers in a row. Divide by the smallest prime that goes into at least one of them, write the results underneath, and bring down any number it does not divide. Repeat until the row is all 1s. The LCM is the product of every divisor used. The GCF is the product of only those divisors that went into every number of their row, which the tool marks with *.

Prime factorization. Factor each number. The LCM takes every prime that appears, at the highest power it reaches in any number; the GCF takes only the primes present in every number, at the lowest power.

Euclid’s algorithm. Divide the larger number by the smaller, then the smaller by the remainder, and so on until the remainder is 0; the last divisor is the GCF. The LCM follows from the product. With more than two numbers, the result so far is paired with the next number.

LCM(a, b) = a × b ÷ GCF(a, b)
GCF(a, b, c) = GCF(GCF(a, b), c)
LCM(a, b, c) = LCM(LCM(a, b), c)

Examples

LCM and GCF of 12, 18, 30 by prime factors

With 12, 18, 30 and Prime factors, the LCM is 180 and the GCF is 6:

  1. Write 12 as a product of primes. 12 = 2² × 3
  2. Write 18 as a product of primes. 18 = 2 × 3²
  3. Write 30 as a product of primes. 30 = 2 × 3 × 5
  4. For the LCM, take every prime that appears, at its highest power. 2² × 3² × 5 = 180
  5. For the GCF, take the primes that appear in every number, at their lowest power. 2 × 3 = 6

Two bells ringing together

One bell rings every 12 minutes and another every 18. They ring together at every common multiple of the two, so first after the LCM of 12, 18, which is 36 minutes. By Euclid:

  1. Divide the larger of 12 and 18 by the smaller, then the divisor by the remainder, until nothing is left over. The last divisor is their GCF. 18 = 1 × 12 + 6, 12 = 2 × 6 + 0, so GCF = 6
  2. The LCM of two numbers is their product divided by their GCF, here 6. 12 × 18 ÷ 6 = 36

LCM × GCF = 36 × 6 = 216, the same as 12 × 18.

Cutting two ropes into equal pieces

Ropes of 48 m and 60 m are to be cut into pieces of one length, as long as possible, with nothing left over. The length must divide both, so it is the GCF of 48, 60: 12 m. With Division, the ladder divides by 2, 2, 2, 2, 3, 5, and of those 2, 2, 3 go into both numbers of their row:

  1. Multiply all the divisors for the LCM. 2 × 2 × 2 × 2 × 3 × 5 = 240
  2. Multiply the divisors marked *, which went into every number of their row, for the GCF. 2 × 2 × 3 = 12

Frequently asked questions

Yes. Highest common factor, greatest common factor and greatest common divisor are three names for the largest whole number that divides every number in the list.
A list with 0 has an LCM of 0, the only multiple of 0. The GCF leaves 0 out, since every number divides it. For 0, 12 and 18 the tool gives an LCM of 0 and a GCF of 6. The GCF is undefined when every number is 0: every number divides 0, so none is the greatest.
With the fractions in lowest terms, the LCM is the LCM of the numerators over the HCF of the denominators, and the HCF is the HCF of the numerators over the LCM of the denominators. For 2/3 and 4/9: the numerators 2 and 4 have LCM 4 and HCF 2, the denominators 3 and 9 have LCM 9 and HCF 3, so the LCM is 4/3 and the HCF is 2/9. Enter the numerators and the denominators as two separate lists.
When no two of them share a factor above 1. 4, 9 and 25 have an LCM of 900, which is 4 × 9 × 25. For two numbers it is enough that their GCF is 1.

See also