Maths

LCM & HCF Calculator

Find the LCM and HCF (GCD) of up to 20 numbers, with prime factors and Euclid’s steps.

By Nitin Raturi · Last reviewed

Your numbers

How to use the LCM & HCF Calculator

Find the lowest common multiple and highest common factor of a list of numbers.

  1. Type or paste your whole numbers.
  2. Read the LCM and HCF at the top of the result.
  3. Check the prime factors of each number to see where both answers come from.
  4. Follow Euclid’s steps for the first two numbers.

Good to know

  • HCF is also called GCD or GCF.
  • For two numbers, HCF × LCM equals their product.

Numbers

The whole numbers whose lowest common multiple and highest common factor you want.

How to fill it in

  • Enter 2 to 20 numbers from 1 to 10,00,000.
  • Separate them with commas, spaces or new lines.

Example

12, 18 and 30 have HCF 6 and LCM 180.

Tip: Numbers with no common factor, like 8 and 15, have HCF 1 and LCM 120, their product.

2 to 20 whole numbers from 1 to 10,00,000.

LCM and HCF of 12, 18, 30

LCM 180 · HCF 6

The smallest number every one of them divides is 180; the largest number that divides all of them is 6.

12
2² × 3
18
2 × 3²
30
2 × 3 × 5
LCM
2² × 3² × 5
HCF
2 × 3

Euclid’s algorithm for the first two numbers:

  1. 18 = 12 × 1 + 6
  2. 12 = 6 × 2 + 0

LCM takes each prime at its highest power; HCF takes each shared prime at its lowest power. HCF is also called GCD or GCF.

How this calculator works

  1. Step 1Factorise12 = 2² × 3Break each number into prime powers.
  2. Step 2LCMhighest powersTake every prime at its highest power.
  3. Step 3HCFlowest powersTake only shared primes, at their lowest power.

The LCM is the smallest number that every number in your list divides. The HCF is the largest number that divides all of them.

The calculator finds the HCF with Euclid’s algorithm and builds the LCM from it, then shows the prime factors so you can check both.

Worked example: 12, 18 and 30

LCM and HCF by prime factors
LCM
each prime at its highest power
HCF
each shared prime at its lowest power
  1. 122² × 3
  2. 182 × 3²
  3. 302 × 3 × 5
  4. LCM2² × 3² × 5180
  5. HCF2 × 36

Every one of 12, 18 and 30 divides 180, and 6 is the largest number that divides all three.

Euclid’s algorithm

HCF of 84 and 36
Rule
HCF(a, b) = HCF(b, a mod b)
  1. 84 ÷ 3684 = 36 × 2 + 12remainder 12
  2. 36 ÷ 1236 = 12 × 3 + 0remainder 0
  3. HCF12

Divide, keep the remainder, and repeat with the divisor and remainder. The last non-zero remainder is the HCF. Then LCM = 84 × 36 ÷ 12 = 252.

Read the result

  • LCM180When things line up again: buses every 12, 18 and 30 minutes meet every 180 minutes.
  • HCF6The biggest equal share: the largest group size that splits all three exactly.

Buses every 15, 20 and 25 minutes all leave together again after 300 minutes.

If two numbers share no prime, their HCF is 1 and the LCM is their product: 8 and 15 give 120.

Assumptions and limits

  • Whole numbers2 to 20 numbers, each from 1 to 10,00,000.
  • No decimalsZero, negatives and fractions are rejected.
  • Exact LCMLarge LCMs are worked in exact integers.
  • Euclid for twoThe division steps are shown for the first pair.

LCM and HCF both come from prime factors.

To see a number’s prime factors, use the prime factorization calculator, or every factor with the factor calculator. Common denominators for fractions are worked out in the fraction calculator.

Common mistakes

  • Mistake: Multiplying all the numbers for the LCM.

    Instead: Only co-prime numbers give their product.

  • Mistake: Taking the highest powers for the HCF.

    Instead: HCF uses the lowest power of each shared prime.

  • Mistake: Using HCF × LCM = product for three numbers.

    Instead: That identity holds for two numbers only.

Checking the method

A separate script re-works every golden value by testing divisors and stepping through multiples, without Euclid or prime factors.

Read how we test our calculators, or browse more maths calculators.

Frequently asked questions

What are the LCM and HCF of 12, 18 and 30?

The LCM is 180 (2² × 3² × 5) and the HCF is 6 (2 × 3).

How do I find the HCF with Euclid’s algorithm?

Divide the larger by the smaller and repeat with the remainder. For 84 and 36 the last non-zero remainder is 12.

Is HCF × LCM always the product of the numbers?

For two numbers, yes: 12 × 252 = 84 × 36. It does not hold for three or more.

What if the numbers have no common factor?

Their HCF is 1 and the LCM is their product: 8 and 15 give 120.

When do buses every 15, 20 and 25 minutes meet again?

After the LCM of the gaps: 300 minutes.

Sources and methodology

The formulas are standard time-value-of-money results. We check every figure against golden values worked out independently, by closed form and by month-by-month simulation; see the methodology.

Written and maintained by Nitin Raturi, a software engineer (about the author). Last reviewed 4 Nov 2026; next review due by . Found an error? Tell us.

Changelog

  • : Initial release.