Skip to content
ToolMug

GCF and LCM Calculator

Enter two or more whole numbers to get their greatest common factor (GCF, also called GCD or HCF) and least common multiple (LCM). The working is shown two ways — by prime factorization and by the Euclidean algorithm — so you can check homework or learn the method.

Runs in your browser — nothing you enter is uploaded

Two or more whole numbers separated by commas or spaces, each up to 10^15.

Greatest common factor (GCF)

6

Least common multiple (LCM)

180

Prime factorization method

  1. 1
    Break 12 into prime factors12 = 2² × 3
  2. 2
    Break 18 into prime factors18 = 2 × 3²
  3. 3
    Break 30 into prime factors30 = 2 × 3 × 5
  4. 4
    GCF: multiply the primes every number shares, each with its lowest power2 × 3 = 6
  5. 5
    LCM: multiply every prime that appears, each with its highest power2² × 3² × 5 = 180

Euclidean algorithm (12 and 18)

  1. 1
    Divide the larger number by the smaller, then divide the divisor by the remainder, and repeat. The last non-zero remainder is the GCF.
  2. 2
    18 = 1 × 12 + 6
  3. 3
    12 = 2 × 6 + 0

With more than two numbers, find the GCF of the first two, then the GCF of that result and the next number, and so on.

How to use

  1. Type the numbers separated by commas or spaces, for example 12, 18, 30.
  2. Read the GCF and LCM at the top.
  3. Follow the prime factorization steps and the Euclidean algorithm underneath.

Options explained

Prime factorization method
Write each number as a product of primes. The GCF uses the primes all numbers share, each with its lowest power; the LCM uses every prime that appears, each with its highest power.
Euclidean algorithm
Divide the larger number by the smaller, then the divisor by the remainder, until the remainder is 0. The last non-zero remainder is the GCF. It is fast even for very large numbers.

Worked examples

Numbers GCF LCM
12, 18 6 36
8, 12, 20 4 120
24, 36, 60 12 360
17, 23 1 391

When the GCF is 1, as with 17 and 23, the numbers are called coprime and their LCM is simply their product.

Where you use them

GCF simplifies fractions (divide top and bottom by the GCF) and splits things into equal groups — the largest square tile that fits a 12 × 18 floor exactly is 6 × 6.

LCM finds a common denominator for adding fractions and answers “when do they line up again” questions — buses every 12 and 18 minutes leave together again after 36 minutes.

Frequently asked questions

What is the difference between GCF, GCD and HCF?

They are the same thing — greatest common factor, greatest common divisor and highest common factor are different names used in different countries.

How are GCF and LCM related?

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

How big can the numbers be?

Each number can be up to 10^15. If the LCM is larger than about 9 × 10^15 it is shown in scientific notation.

Privacy

This tool runs entirely in your browser. Your files and text are processed on your device and are never uploaded to our servers.

Related tools