GCF and LCM Calculator

Greatest common factor (GCF) and least common multiple (LCM) of two or more numbers, with prime factors.

Two to 20 whole numbers, separated by commas or spaces.

Greatest common factor (GCF)

6

LCM: 180. The GCF is also called the GCD or the highest common factor.

Least common multiple (LCM)
180
Prime factors of 12
2^2 × 3
Prime factors of 18
2 × 3^2
Prime factors of 30
2 × 3 × 5

For 12, 18, 30, the GCF is 6 and the LCM is 180.

Add this calculator to your website

Free to use on any site or blog. Paste this code where you want the calculator to appear. It stays up to date, needs no account, and keeps your visitors' numbers in their own browser.

Preview

How it works

The greatest common factor (GCF) of some numbers is the largest number that divides every one of them with no remainder. It is also called the greatest common divisor (GCD) or highest common factor (HCF). The least common multiple (LCM) is the smallest number that every one of them divides into.

The tool finds the GCF with Euclid's algorithm: repeatedly replace the larger number by the remainder after dividing, until the remainder is 0. For two numbers, LCM = a × b ÷ GCF. For more numbers, it works through the list one at a time. It also factors each number into primes, so you can see the method you would use by hand.

Use the GCF to reduce a fraction to lowest terms or to split things into equal groups. Use the LCM to find a common denominator for adding fractions, or to see when two repeating events line up again.

Check it by hand: split each number into prime factors. 12 = 2² × 3, 18 = 2 × 3² and 30 = 2 × 3 × 5. The GCF takes the smallest power of the primes they all share: 2 × 3 = 6. The LCM takes the largest power of every prime: 2² × 3² × 5 = 180. For two numbers, GCF × LCM equals their product: for 12 and 18, 6 × 36 = 216 = 12 × 18.

GCF(a, b): repeat (a, b) → (b, a mod b) until b = 0
LCM(a, b) = a × b ÷ GCF(a, b)
More than two numbers: fold the same step across the list

Worked example

For 12, 18 and 30: 12 = 2² × 3, 18 = 2 × 3², 30 = 2 × 3 × 5. The GCF takes the lowest power of each shared prime: 2 × 3 = 6. The LCM takes the highest power of every prime: 2² × 3² × 5 = 180.

Check: 6 divides 12, 18 and 30. And 180 ÷ 12 = 15, 180 ÷ 18 = 10 and 180 ÷ 30 = 6, all whole numbers.

Good to know

  • Only positive whole numbers up to 1,000,000,000,000 are accepted, up to 20 at a time.
  • The prime factors of the first 8 numbers are shown. The GCF and LCM use every number you enter.
  • Very large LCMs can run to many digits. They are exact because the tool uses whole-number arithmetic.

Questions people ask

What is the difference between GCF and LCM?

The GCF is the biggest number that divides all your numbers. The LCM is the smallest number that all your numbers divide into. For 4 and 6, the GCF is 2 and the LCM is 12.

Are GCF, GCD and HCF the same thing?

Yes. Greatest common factor, greatest common divisor and highest common factor all mean the same number. Different countries and textbooks use different names.

How do I find the LCM of two numbers?

Multiply them and divide by their GCF. For 8 and 12 the GCF is 4, so the LCM is 8 × 12 ÷ 4 = 24.

How do I find the GCF by prime factors?

Write each number as a product of primes. Multiply the primes they share, using the smallest power of each. For 12 and 18, the shared part is 2 × 3 = 6.

What is the GCF of two prime numbers?

It is 1, because two different primes share no factor other than 1. Numbers like that are called coprime.

What are the GCF and LCM of 12 and 18?

The GCF is 6 and the LCM is 36. Check: 6 × 36 = 216, which is 12 × 18.

Part of the guide: Math and study calculators: percentages, fractions, GPA and everyday sums

Formulas and text last checked on 14 October 2026. Everything is calculated in your browser, so nothing you enter is sent or stored. Spotted a mistake? Tell us and we will fix it.