CalcWise All calculators

Numbers and fractions

LCM and GCF calculator

Type two or more whole numbers. You get the greatest common factor and the least common multiple, plus the prime factors that explain both.

Press Calculate to see the answer and every step of the working.

How it works

Every whole number above 1 can be built by multiplying prime numbers together, and there is only one way to do it. 12 is 2 x 2 x 3, and nothing else. Those prime "building blocks" make LCM and GCF easy.

The greatest common factor is the biggest number that divides into all of them. Take only the primes that appear in every number, at the smallest power. The least common multiple is the smallest number they all divide into. Take every prime that appears anywhere, at the biggest power.

You will use the GCF to simplify fractions and the LCM to find common denominators, so these two show up all the time.

The formula

  • Write each number as a product of primes
  • GCF = product of shared primes, each at its lowest power
  • LCM = product of all primes, each at its highest power
  • For two numbers: GCF x LCM = a x b

Worked example

Find the GCF and LCM of 12, 18 and 30.

  • 12 = 2² x 3
  • 18 = 2 x 3²
  • 30 = 2 x 3 x 5

All three share one 2 and one 3, so the GCF is 6. For the LCM, take 2², 3² and 5: 4 x 9 x 5 = 180. Three buses leaving every 12, 18 and 30 minutes will next leave together after 180 minutes, or three hours.

Common questions

Is GCF the same as HCF and GCD?

Yes. Greatest common factor, highest common factor and greatest common divisor are three names for the same thing. Different countries and textbooks prefer different ones.

What if the GCF is 1?

Then the numbers are called co-prime or relatively prime. Their LCM is simply all of them multiplied together, for two numbers.

When do I use LCM and when do I use GCF?

Use LCM when things need to line up or meet again (common denominators, repeating schedules). Use GCF when you are splitting things into equal groups as large as possible (simplifying fractions, packing items evenly).