X-Calculator
Math Updated November 23, 2026

GCF and LCM Calculator

Find the GCF and LCM of two or more whole numbers, with the prime factorization of each one.

Whole numbers (2 or more, separated by commas or spaces)
Advertisement
Advertisement

This GCF and LCM calculator finds the greatest common factor and the least common multiple of two or more whole numbers at once. It also lists the prime factorization of every number, so you can see exactly which primes build the GCF and which build the LCM.

What GCF and LCM mean

The greatest common factor (GCF), also called the greatest common divisor (GCD) or highest common factor (HCF), is the largest whole number that divides every number in the set without a remainder. The GCF of 12 and 18 is 6, because 6 divides both and nothing larger does.

The least common multiple (LCM) is the smallest positive number that every number in the set divides into evenly. The LCM of 4 and 6 is 12: the multiples of 4 are 4, 8, 12, 16…, the multiples of 6 are 6, 12, 18…, and 12 is the first one they share.

How to find the GCF and LCM with prime factorization

  1. Write each number as a product of primes: 12 = 2² × 3, 18 = 2 × 3², 30 = 2 × 3 × 5.
  2. For the GCF, keep only the primes that appear in every number, each at its lowest power: 2¹ × 3¹ = 6.
  3. For the LCM, take every prime that appears anywhere, each at its highest power: 2² × 3² × 5 = 180.
GCF = product of common primes, lowest exponents
LCM = product of all primes, highest exponents
For two numbers:  GCF(a, b) × LCM(a, b) = a × b
Advertisement
Advertisement

The Euclidean algorithm (fast GCF for big numbers)

Factoring large numbers is slow, so calculators use Euclid’s method: replace the larger number with the remainder of dividing it by the smaller, and repeat until the remainder is 0. The last non-zero remainder is the GCF.

GCF(1071, 462): 1071 = 2 × 462 + 147
                462 = 3 × 147 + 21
                147 = 7 × 21 + 0   → GCF = 21

Once you have the GCF of two numbers, the LCM follows directly: LCM = a × b ÷ GCF. For 1071 and 462, that is 494,802 ÷ 21 = 23,562. For three or more numbers, apply the rule pairwise: GCF(a, b, c) = GCF(GCF(a, b), c), and the same for the LCM.

Worked examples

  • 84 and 126: 84 = 2² × 3 × 7, 126 = 2 × 3² × 7. GCF = 2 × 3 × 7 = 42; LCM = 2² × 3² × 7 = 252. Check: 42 × 252 = 10,584 = 84 × 126.
  • 8 and 9: 8 = 2³ and 9 = 3² share no prime, so GCF = 1 (they are coprime) and LCM = 8 × 9 = 72.
  • 4, 6, 8, 10: every number is even, so GCF = 2. LCM = 2³ × 3 × 5 = 120.
  • 1001 and 2431: 1001 = 7 × 11 × 13 and 2431 = 11 × 13 × 17. GCF = 11 × 13 = 143; LCM = 7 × 11 × 13 × 17 = 17,017.

GCF and LCM of common pairs

Numbers GCF LCM
6 and 8 2 24
12 and 16 4 48
15 and 20 5 60
18 and 24 6 72
24 and 36 12 72
9 and 14 1 126
2, 3, 4, 5, 6 1 60
1 through 10 1 2,520

Where you use GCF and LCM

  • Simplifying fractions: divide the numerator and denominator by their GCF. 84/126 ÷ 42 = 2/3. The fraction calculator does this automatically.
  • Adding fractions: the LCM of the denominators is the least common denominator. For 1/4 + 1/6, LCM(4, 6) = 12, so 3/12 + 2/12 = 5/12.
  • Simplifying ratios: 24:36 reduces to 2:3 by dividing by the GCF of 12. See the ratio calculator.
  • Scheduling and cycles: if one bus comes every 12 minutes and another every 18, they arrive together every LCM(12, 18) = 36 minutes.
  • Tiling and cutting: the largest square tile that fits a 120 × 84 inch floor with no cutting has a side of GCF(120, 84) = 12 inches.

Common mistakes

  • Swapping the rules. The GCF uses the lowest powers of shared primes, the LCM the highest powers of all primes. The GCF can never be larger than the smallest number; the LCM can never be smaller than the largest.
  • Using the product shortcut for three numbers. GCF × LCM = a × b only works for two numbers. For 4, 6 and 8: 2 × 24 = 48, but 4 × 6 × 8 = 192.
  • Treating 1 as prime. It is not; numbers with no common prime simply have a GCF of 1.

Frequently Asked Questions

What is the difference between GCF and LCM?

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

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 number.

What is the GCF of two prime numbers?

Two different primes share no factor except 1, so their GCF is 1 and their LCM is their product. For 7 and 11, the LCM is 77.

How are GCF and LCM related?

For any two positive whole numbers a and b, GCF(a, b) × LCM(a, b) = a × b. So if you know one, you can find the other by division.

Can the LCM be equal to one of the numbers?

Yes, when one number is a multiple of all the others. The LCM of 4 and 12 is 12, and their GCF is 4.

Advertisement
Advertisement
Related

You may also need

All Math Calculators
Advertisement