Skip to content
DayUtils

LCM and GCF Calculator – Least Common Multiple and Greatest Common Factor

Find the greatest common factor (also called the highest common factor, HCF, or greatest common divisor, GCD) and the least common multiple of two or more whole numbers, with the prime factorisation of each number to show how it is worked out.

Loading tool…

How to use the LCM and GCF calculator

Type two or more whole numbers separated by commas or spaces. You’ll see:

  • the greatest common factor (GCF),
  • the least common multiple (LCM),
  • a table of each number’s prime factorisation.

How it’s worked out

Prime factorisation writes a number as a product of primes: 360 = 2³ × 3² × 5.

GCF = product of the shared primes, each at its lowest power
LCM = product of every prime that appears, each at its highest power

For two numbers there is also a shortcut using Euclid’s algorithm: repeatedly replace the larger number by the remainder when it is divided by the smaller, until the remainder is 0. The last non-zero number is the GCF. Then:

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

Worked example: 12, 18 and 30

NumberPrime factors
122² × 3
182 × 3²
302 × 3 × 5
  • Shared primes at the lowest power: 2¹ and 3¹ → GCF = 6
  • All primes at the highest power: 2², 3² and 5 → LCM = 4 × 9 × 5 = 180

Euclid’s algorithm for 84 and 36

84 ÷ 36 = 2 remainder 12; 36 ÷ 12 = 3 remainder 0. The GCF is 12, and the LCM is 84 × 36 ÷ 12 = 252.

Real-world uses

  • Adding fractions: the LCM of the denominators is the lowest common denominator. For 1/12 + 1/18, use 36.
  • Simplifying fractions: divide top and bottom by the GCF. 18/30 ÷ 6 = 3/5.
  • Scheduling: lights flashing every 4 and 6 seconds flash together every 12 seconds.
  • Packaging and grouping: the GCF gives the largest equal groups without leftovers.
  • Tiling: the largest square tile that exactly covers a 240 cm × 180 cm floor has a side of GCF(240, 180) = 60 cm.

Prime numbers

A prime number has exactly two factors, 1 and itself: 2, 3, 5, 7, 11, 13 and so on. Every whole number above 1 can be written as a product of primes in exactly one way, which is why prime factorisation is such a reliable method for finding the GCF and LCM. If a number’s only prime factor is itself, as with 97, the table shows just that number.

Tips

  • If one number divides all the others, it is the GCF — for 6, 12 and 18 the GCF is 6.
  • If the numbers share no prime factors (they are “coprime”), the GCF is 1 and the LCM is their product.
  • The LCM is always at least as large as the largest number; the GCF is never larger than the smallest.

Work with the results in the fraction calculator or the ratio calculator, or explore powers with the exponent calculator.

Frequently asked questions

What is the GCF of 12, 18 and 30?

6. Their prime factorisations are 2² × 3, 2 × 3² and 2 × 3 × 5. The primes they all share are one 2 and one 3, so the GCF is 2 × 3 = 6.

What is the LCM of 12, 18 and 30?

180. Take every prime at its highest power: 2², 3² and 5, so the LCM is 4 × 9 × 5 = 180.

Are GCF, HCF and GCD the same?

Yes. Greatest common factor (US), highest common factor (UK and India) and greatest common divisor (computing and higher maths) all mean the largest number that divides every number in the list exactly.

What is the relationship between LCM and GCF?

For two numbers, LCM × GCF = the product of the numbers. For 12 and 18: GCF 6 × LCM 36 = 216 = 12 × 18.

When do I use the LCM?

To find a common denominator when adding fractions, or to work out when repeating events line up — for example two buses every 12 and 18 minutes leave together every 36 minutes.

When do I use the GCF?

To simplify fractions and ratios, and to split things into the largest equal groups — for example 12 apples and 18 oranges make at most 6 identical bags.

Last updated: