Skip to content
DailyCalc logo

Math · Free tool

LCM & GCF Calculator

Least common multiple and greatest common factor of up to 20 numbers, with Euclid's steps.

The greatest common factor (GCF) — also called the highest common factor (HCF) or greatest common divisor (GCD) — is the largest whole number that divides every number in a set exactly. The least common multiple (LCM) is the smallest whole number that every number in the set divides into. They answer opposite questions: GCF breaks things into the largest equal groups; LCM finds when repeating cycles line up again.

This calculator handles 2 to 20 positive whole numbers. It uses Euclid's algorithm, the 2,300-year-old method that repeatedly replaces the larger number with the remainder of a division, and shows those steps for the first pair so you can follow the working. The LCM is then built from the GCF using LCM(a, b) = a × b ÷ GCF(a, b).

You will meet both in fraction arithmetic (the LCM of denominators is the lowest common denominator; the GCF simplifies a fraction), in scheduling problems, and in tiling and packing questions.

By DailyCalc Editorial Team · Updated · 5-min read · 3 sources cited

● LCM & GCF calculator

Math →

Euclid's algorithm and the LCM formula

GCF(a, b) = GCF(b, a mod b), until the remainder is 0; LCM(a, b) = a × b ÷ GCF(a, b)

Divide the larger number by the smaller and keep the remainder. Repeat with the smaller number and that remainder. When the remainder reaches 0, the last non-zero divisor is the GCF. For more than two numbers, apply the rule pairwise: GCF(a, b, c) = GCF(GCF(a, b), c), and the same for LCM.

  • a, b: Positive whole numbers.
  • a mod b: The remainder when a is divided by b.

Worked example: 12, 18 and 30

Find both the GCF and the LCM:

  1. GCF(12, 18): 18 = 1 × 12 + 6; 12 = 2 × 6 + 0 → GCF = 6.
  2. GCF(6, 30): 30 = 5 × 6 + 0 → GCF of all three = 6.
  3. LCM(12, 18) = 12 × 18 ÷ 6 = 36.
  4. LCM(36, 30): GCF(36, 30) = 6, so LCM = 36 × 30 ÷ 6 = 180.
  5. Check: 180 ÷ 12 = 15, 180 ÷ 18 = 10, 180 ÷ 30 = 6 — all whole numbers ✓.

Result: GCF(12, 18, 30) = 6 and LCM(12, 18, 30) = 180.

How to use this calculator

One box, any separator.

Step 1: Enter 2–20 whole numbers

Separate them with commas or spaces, for example 12, 18, 30. Decimals and negative numbers are not accepted.

Step 2: Calculate

You get the GCF, the LCM and Euclid's steps for the first two numbers.

Where LCM and GCF come up

Everyday and classroom problems:

Adding fractions

To add 5/12 + 7/18, use the LCM of 12 and 18 (36) as the common denominator: 15/36 + 14/36 = 29/36.

Simplifying fractions

Divide top and bottom by their GCF: 84/60 has GCF 12, so it simplifies to 7/5.

Scheduling

Buses every 12 and 18 minutes leave together again after LCM(12, 18) = 36 minutes.

Equal groups

48 pens and 180 pencils packed into identical kits with nothing left over: GCF(48, 180) = 12 kits.

Gears and cycles

Gear teeth counts and repeating patterns realign after their LCM.

Pro tips

Shortcuts worth knowing:

  • For any two numbers, GCF × LCM = a × b — a quick check on your answer.
  • If one number divides the other, the smaller is the GCF and the larger is the LCM.
  • Two consecutive whole numbers always have a GCF of 1.
  • Euclid's algorithm is much faster than listing factors for large numbers.

Common mistakes

Where students slip:

Multiplying instead of finding the LCM

12 × 18 = 216 is a common multiple, but the least common multiple is 36.

Mixing up GCF and LCM

The GCF can be no larger than the smallest number; the LCM is at least as large as the largest.

Applying the two-number formula to three at once

a × b × c ÷ GCF(a, b, c) is not the LCM. Work pairwise.

Stopping Euclid too early

Keep going until the remainder is exactly 0; the GCF is the last non-zero divisor.

Sources & references

The formula, thresholds and guidance on this page were checked against these primary sources. Written and reviewed by DailyCalc Editorial Team; last updated . Spotted an error? Tell us.

  1. Math is Fun — Least common multiple
  2. Math is Fun — Greatest common factor
  3. Euclidean algorithm (greatest common divisor)

FAQs

Frequently asked questions

6. It is the largest number that divides all three exactly.