United Kingdom · Maths & Statistics

LCM and HCF Calculator

Two or more positive whole numbers, separated by commas or spaces.
HCF and LCM—

Enter two or more whole numbers. The calculator factorises each into primes and shows the working — because HCF and LCM both fall straight out of the factorisation once you know which powers to take.

How do you find the HCF and LCM?

Factorise every number into primes. The HCF takes the lowest power of each prime that appears in every number. The LCM takes the highest power of every prime that appears in any of them. One factorisation gives both answers, which is why it is worth doing properly rather than guessing.

How to use this calculator

  1. Enter positive whole numbersHCF and LCM are defined for integers. Decimals and negatives are rejected rather than silently rounded.
  2. Two or more numbersThe method extends naturally to three or four numbers, and the breakdown shows the factorisation of each so the working stays visible.
  3. Read the factorisationsThey are the actual working. Once you have them, both answers follow from taking the lowest and highest powers — no separate method is needed.
  4. Use the check rowFor two numbers, HCF × LCM equals their product. That is a fast verification, and the breakdown shows it.

One factorisation, two answers

Both quantities come from the same place, which is why factorising properly is worth the effort rather than hunting for factors by trial.

Every whole number above 1 has exactly one prime factorisation. That uniqueness — the fundamental theorem of arithmetic — is what makes the method work at all. It means 12 is 2² × 3 and can be written no other way, so comparing factorisations compares the numbers themselves.

The highest common factor is the largest number dividing all of them. A prime can only appear in a common factor as many times as it appears in the number that has fewest of it — so take the minimum power. If a prime is missing from any of the numbers entirely, its minimum is zero and it drops out.

The lowest common multiple is the smallest number they all divide into. A multiple must contain enough of each prime to satisfy the greediest number — so take the maximum power. Every prime that appears anywhere is included.

That symmetry is what makes it memorable: HCF is the minimum of each shared prime, LCM is the maximum of every prime.

For two numbers there is a shortcut worth knowing. HCF × LCM always equals the product of the two numbers, because between them the minimum and maximum powers account for exactly the powers present in each. It makes a fast check.

That relationship does not extend to three or more numbers. For 4, 6 and 8 the HCF is 2 and the LCM is 24, giving 48 — while the product is 192. Anyone applying the two-number shortcut to three numbers will get a wrong answer, which is why the factorisation method is the reliable one.

FormulaHCF takes the lowest power of shared primes; LCM takes the highest power of all primes

Worked example: 12 and 18

Factorise each.

12 divides by 2 to give 6, by 2 again to give 3, and 3 is prime. So 12 = 2² × 3.

18 divides by 2 to give 9, then 9 is 3 × 3. So 18 = 2 × 3².

The primes involved are 2 and 3.

For the HCF, take the lowest power of each. The prime 2 appears squared in 12 and once in 18, so the minimum is 2¹. The prime 3 appears once in 12 and squared in 18, so the minimum is 3¹.

HCF = 2 × 3 = 6.

For the LCM, take the highest power of each. For 2 that is 2², and for 3 that is 3².

LCM = 4 × 9 = 36.

Check: 6 × 36 = 216, and 12 × 18 = 216 ✓.

Two further sanity checks worth doing. Dividing each number by the HCF gives 12 ÷ 6 = 2 and 18 ÷ 6 = 3, which share no common factor — as they must, since all of it went into the HCF. And dividing the LCM by each number gives 36 ÷ 12 = 3 and 36 ÷ 18 = 2, both whole numbers, confirming it really is a common multiple.

Now contrast with 8 and 15. 8 = 2³ and 15 = 3 × 5. No prime is shared, so the HCF is 1 — they are coprime — and the LCM is simply their product, 120.

Common pairs

NumbersFactorisationsHCFLCM
12, 182²×3 and 2×3²636
8, 122³ and 2²×3424
15, 253×5 and 5²575
9, 163² and 2⁴1 — coprime144
24, 362³×3 and 2²×3²1272
6, 10, 152×3, 2×5, 3×5130

The last row is instructive. No prime appears in all three numbers, so the HCF is 1 — yet every pair shares a factor. That is the difference between pairwise coprime and coprime as a set, and it is also the row where the HCF × LCM shortcut fails: 1 × 30 = 30, while the product of the three numbers is 900.

Where HCF and LCM are actually used

These are not abstract exercises — both answer specific practical questions, and knowing which one you need is most of the work.

The HCF answers questions about dividing things into equal groups. Cutting two lengths of timber, 12 m and 18 m, into identical pieces with none wasted means the longest possible piece is 6 m. Arranging 24 red and 36 blue tiles into identical mixed sets means at most 12 sets. Anything of the form "largest equal portion" is an HCF question.

Simplifying fractions is the same operation. Reducing 12/18 to lowest terms means dividing both by their HCF of 6, giving 2/3. That is why factorising is the honest way to simplify rather than repeatedly halving and hoping.

The LCM answers questions about things coinciding. Two buses leaving every 12 and 18 minutes next depart together after 36 minutes. Two cogs with 12 and 18 teeth return to their starting alignment after 36 teeth have passed. Anything of the form "when do these next line up" is an LCM question.

Adding fractions is the everyday case. To add 1/12 and 1/18 you need a common denominator, and the lowest one is the LCM of 12 and 18 — that is 36, giving 3/36 + 2/36 = 5/36. Using the product of 216 instead works but leaves a much larger fraction to simplify afterwards.

The quick test for which you need: if the answer must be smaller than the numbers, you want the HCF. If it must be larger, you want the LCM. Students who mix them up almost always notice immediately if they apply that check.

The Euclidean algorithm is a faster route to the HCF for large numbers, repeatedly replacing the larger number with the remainder on division. It does not give the factorisation, so it does not hand you the LCM at the same time — but for two very large numbers it is far quicker than factorising.

The terms vary by region. HCF and GCD — greatest common divisor — are the same thing, as are LCM and lowest common denominator when used about fractions. UK schools generally say HCF; most software and American texts say GCD.

Assumptions and limitations

  • Positive whole numbers only — HCF and LCM are undefined for decimals
  • Uses trial division, which is fast for ordinary numbers but not for very large ones
  • Numbers above a billion are rejected rather than left to run
  • The HCF × LCM shortcut applies to two numbers only, not three or more
  • Does not use the Euclidean algorithm, which is faster for large pairs but gives no factorisation
  • Does not handle algebraic expressions, only integers
  • Very large LCMs can exceed exact integer representation

Questions people ask about this in United Kingdom

How do you find the HCF and LCM?

Factorise every number into primes. The HCF takes the lowest power of each prime appearing in all of them; the LCM takes the highest power of every prime appearing in any.

One factorisation gives both.

What is the difference between HCF and GCD?

Nothing — they are the same quantity. UK schools say highest common factor; most software and American texts say greatest common divisor.

Is HCF × LCM always the product?

For two numbers, yes — always. For three or more it fails.

With 6, 10 and 15 the HCF is 1 and the LCM is 30, giving 30, while the product is 900.

What does coprime mean?

Two numbers sharing no prime factor, so their HCF is 1. Their LCM is then simply their product.

9 and 16 are coprime despite neither being prime.

Which do I need for adding fractions?

The LCM of the denominators. For 1/12 + 1/18 the LCM is 36, giving 3/36 + 2/36 = 5/36.

The product would work too but leaves more simplifying afterwards.

Which do I need for simplifying a fraction?

The HCF. Divide the numerator and denominator by it — 12/18 both divide by 6, giving 2/3.

That gets to lowest terms in one step.

How do I know which one a word problem wants?

If the answer must be smaller than the numbers, it is the HCF — largest equal pieces, biggest groups.

If it must be larger, it is the LCM — when things next coincide.

Method, source and review date

How it is worked out
Prime factorisation by trial division
Formula used
HCF = Π p^min(powers); LCM = Π p^max(powers)
Checked against
Standard arithmetic
Last reviewed
Confidence
High

Spotted a figure that has moved, or a formula you can show is wrong? Tell us — send a correction. Fixes to rates and formulas are treated as urgent.

Disclaimer

This calculator gives an estimate for guidance only. Check the figures against your own measurements or paperwork before you commit money to them.