Calci.inCalculate Today for a Better Tomorrow

LCM and HCF Calculator

Least common multiple and highest common factor of any numbers

Free, no sign-up · Reviewed

LCM and HCF details

Whole numbers above zero, separated by commas or spaces. Up to ten.

The guide

Finding the LCM and HCF, with the method schools teach

What the LCM and HCF mean, how to find them by prime factors and by the division method, the rule linking the two, and the word problems where each one is the answer.

Last reviewed · 1,262 words

In short

  • The HCF is the largest number that divides all the given numbers. The LCM is the smallest number that all of them divide into.
  • By prime factors, the HCF takes common primes at their lowest power and the LCM takes every prime at its highest power.
  • For two numbers, LCM × HCF = the product of the numbers. This does not hold for three or more.
  • Questions about "largest" sizes or groups usually want the HCF. Questions about when things next "coincide" usually want the LCM.
  • Numbers with an HCF of 1, such as 8 and 15, are called coprime.

The LCM and HCF turn up early in school mathematics and keep turning up afterwards, in adding fractions, in simplifying ratios and in aptitude tests. Students often mix them up, because the method for each looks like the other. This page explains what each one means, walks through the two methods taught in Indian schools, and shows how to recognise which one a word problem wants.

What the two terms mean

A factor of a number divides it exactly. A multiple is what you get by multiplying it. So 6 is a factor of 18, and 18 is a multiple of 6.

The HCF, or highest common factor, is the largest number that is a factor of all the given numbers. It is also called the GCD (greatest common divisor) or GCF. The HCF of 12 and 18 is 6, because 6 divides both and nothing larger does.

The LCM, or least common multiple, is the smallest number that is a multiple of all of them. The LCM of 12 and 18 is 36. Multiples of 12 are 12, 24, 36, and multiples of 18 are 18, 36, so 36 is the first they share.

Note the direction of each. The HCF can never be larger than the smallest number, and the LCM can never be smaller than the largest.

Method 1: prime factors

Write each number as a product of primes:

  • 12 = 2² × 3
  • 18 = 2 × 3²
  • 24 = 2³ × 3

For the HCF, take only the primes found in every number, each at its lowest power. All three contain 2 and 3. The lowest power of 2 is 2¹, and the lowest of 3 is 3¹, so the HCF is 2 × 3 = 6.

For the LCM, take every prime that appears, each at its highest power. The highest power of 2 is 2³, and of 3 is 3², so the LCM is 8 × 9 = 72.

HCF = product of common primes at lowest power

LCM = product of all primes at highest power

The calculator shows the prime factors of each number, so you can follow this for your own numbers.

Method 2: repeated division

For the LCM, write the numbers in a row and divide by a prime that goes into at least two of them, carrying down any number that does not divide. Keep going until nothing shares a factor. Then multiply all the divisors and the numbers left at the bottom.

Take 12, 18 and 24:

Divide byRow
212, 18, 24
26, 9, 12
33, 9, 6
31, 3, 2
1, 1, 2

The LCM is 2 × 2 × 3 × 3 × 2 = 72.

For the HCF, schools teach long division, known as Euclid's method. Divide the larger number by the smaller, then divide the divisor by the remainder, and repeat until the remainder is zero. The last divisor is the HCF. For 18 and 12: 18 ÷ 12 leaves 6, and 12 ÷ 6 leaves 0, so the HCF is 6. To handle three numbers, find the HCF of the first two and then the HCF of that result with the third.

For two numbers:

LCM × HCF = first number × second number

For 12 and 18: 36 × 6 = 216, and 12 × 18 = 216. This gives a quick way to find one from the other. If two numbers multiply to 216 and their HCF is 6, the LCM must be 36.

The rule does not work for three or more numbers. For 12, 18 and 24, the LCM × HCF is 72 × 6 = 432, while the product is 5,184. The calculator says so when you enter more than two numbers.

Which one does the question want?

Word problems rarely say LCM or HCF. Look at what is being asked.

HCF: splitting into the largest equal pieces. A shopkeeper has 48 red and 60 blue pens and wants identical packets with none left over. What is the most packets possible? The HCF of 48 and 60 is 12, so 12 packets, each holding 4 red and 5 blue pens.

HCF: the largest tile or measure. A room is 12 m by 18 m. What is the largest square tile that fits exactly without cutting? The HCF of 12 and 18 is 6, so a 6 m tile, in this rather unlikely room.

LCM: things happening together again. Two bells ring every 12 and 18 minutes. They ring together now. When will they next ring together? In 36 minutes, the LCM.

LCM: the smallest amount that fits every group. What is the smallest number of sweets that can be shared equally among 4, 6 or 8 children? The LCM of 4, 6 and 8 is 24.

A quick test: if the answer must be smaller than the given numbers, think HCF. If it must be larger, think LCM.

Where else they appear

Adding fractions. To add 1/12 and 1/18, you need a common denominator, and the LCM gives the smallest: 3/36 + 2/36 = 5/36. The fraction calculator shows this working.

Simplifying ratios. Dividing both terms by their HCF gives the lowest form. 12 : 18 becomes 2 : 3, as the ratio calculator shows.

Coprime numbers. Two numbers with an HCF of 1 share no factor, such as 8 and 15. Their LCM is just their product, 120. Any two consecutive numbers are coprime, and two different primes always are.

Exam shortcut. The HCF of a set always divides their differences. For 12, 18 and 24, the differences are 6, 6 and 12, so the HCF must divide 6. This narrows down the answer fast.

Exam-style questions

Smallest number with a remainder. What is the smallest number that leaves a remainder of 5 when divided by 12, 18 and 24? Find the LCM, which is 72, and add the remainder: 77. Check: 77 ÷ 12 is 6 remainder 5, and the same holds for 18 and 24.

Largest number with remainders. What is the largest number that divides 40 and 62, leaving remainders of 4 and 2? Take the remainders away first: 36 and 60. Their HCF is 12, so the answer is 12.

Numbers in a ratio. Two numbers are in the ratio 3 : 4 and their HCF is 5. The numbers must be 3 × 5 = 15 and 4 × 5 = 20, and their LCM is 60. Check with the rule: 60 × 5 = 300, which equals 15 × 20.

Traffic lights. Three signals change every 30, 45 and 60 seconds. They change together now, so they next do so after the LCM of the three, which is 180 seconds, or 3 minutes.

LCM and HCF of fractions. There is a pair of rules for fractions in lowest terms:

HCF of fractions = HCF of numerators ÷ LCM of denominators

LCM of fractions = LCM of numerators ÷ HCF of denominators

For 2/3 and 4/9, the HCF is 2/9 and the LCM is 4/3. The calculator takes whole numbers only, so use it on the numerators and denominators separately.

A quick check on any answer. The HCF always divides the LCM exactly. If your answers fail this test, one of them is wrong. For 12 and 18, 36 ÷ 6 = 6, so the pair passes.

What this calculator assumes

  • The numbers are whole numbers above zero. Fractions and decimals are not accepted.
  • You can enter between two and ten numbers, separated by commas or spaces.
  • The answer is exact for large numbers, because the working uses whole-number arithmetic rather than floating point.
  • HCF, GCD and GCF are treated as the same thing, as they are.
  • The table shows prime factors in ascending order, with powers.

Sources

Frequently asked questions

What is the difference between LCM and HCF?

The HCF is the largest number that divides all the given numbers, and the LCM is the smallest number that all of them divide into. For 12 and 18, the HCF is 6 and the LCM is 36.

How do I find the LCM by prime factors?

Write each number as prime factors and take each prime at its highest power. 12 = 2² × 3 and 18 = 2 × 3², so the LCM is 2² × 3² = 36.

How do I find the HCF by prime factors?

Take only the primes common to all the numbers, each at its lowest power. 12 = 2² × 3 and 18 = 2 × 3² share 2 × 3 = 6.

Is HCF the same as GCD?

Yes. HCF (highest common factor), GCD (greatest common divisor) and GCF (greatest common factor) all mean the same thing.

What is the relation between LCM and HCF?

For two numbers, LCM × HCF = the product of the numbers. For 12 and 18, 36 × 6 = 216, which is 12 × 18. This does not hold for three or more numbers.