GCF & LCM Calculator

Enter two or more whole numbers to find their greatest common factor (GCF) and least common multiple (LCM). The calculator shows the prime factorization of each number and, for two numbers, the Euclidean algorithm.

Grades 4–8FreeNo sign-up

Try:

What are the GCF and LCM?

The greatest common factor (GCF) — also called the greatest common divisor (GCD) or highest common factor (HCF) — is the largest whole number that divides evenly into every number in the list. The least common multiple (LCM) is the smallest positive number that every number in the list divides into.

Example: for 12 and 18, the factors of 12 are 1, 2, 3, 4, 6, 12 and the factors of 18 are 1, 2, 3, 6, 9, 18. The largest shared factor is 6. The multiples of 12 are 12, 24, 36, … and of 18 are 18, 36, … — the first shared multiple is 36.

Method 1: prime factorization

Break every number into primes, then:

NumberPrime factorization
122² × 3
182 × 3²
GCF2¹ × 3¹ = 6
LCM2² × 3² = 36

Method 2: the Euclidean algorithm

For large numbers, factoring is slow. Euclid's algorithm (about 300 BC!) is much faster: divide the larger number by the smaller, then replace the pair with the smaller number and the remainder. Repeat until the remainder is 0. The last non-zero remainder is the GCF.

GCF(48, 180): 180 = 3 × 48 + 36 → 48 = 1 × 36 + 12 → 36 = 3 × 12 + 0. The GCF is 12.

Once you know the GCF of two numbers, the LCM comes for free: LCM(a, b) = a × b ÷ GCF(a, b). For 48 and 180: 48 × 180 ÷ 12 = 720.

Where you'll use them

Frequently asked questions

What is the difference between GCF and LCM?

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

Is GCF the same as GCD and HCF?

Yes. Greatest common factor, greatest common divisor and highest common factor are three names for the same thing.

How do I find the LCM of two numbers quickly?

Find their GCF, then use LCM = a × b ÷ GCF. For 8 and 12, the GCF is 4, so the LCM is 8 × 12 ÷ 4 = 24.

What if the GCF is 1?

Then the numbers are called relatively prime or coprime. Their LCM is simply their product — for 9 and 16 it is 144.

How many numbers can I enter?

Up to 10 whole numbers, each up to one trillion. The Euclidean algorithm steps are shown when you enter exactly two numbers.