LCM & GCF Calculator

In short: the GCF (greatest common factor) is the largest number that divides all your numbers — for 12 and 18 it is 6. The LCM (least common multiple) is the smallest number all your numbers divide into — here 36. One looks down at shared divisors, the other up at shared multiples.

Two directions from the same factorizations

Write each number as a product of primes and both answers fall out. 12 = 2² × 3 and 18 = 2 × 3². The GCF takes the primes the numbers share, at the lower power: 2¹ × 3¹ = 6 — anything bigger would need a prime power one of the numbers does not have, and so could not divide it. The LCM takes every prime that appears, at the higher power: 2² × 3² = 36 — anything smaller would be missing a power one of the numbers needs, and so could not be divided by it. This calculator shows the factorization of each input precisely so the two answers can be read off and checked, rather than trusted.

For two numbers there is a famous shortcut: LCM × GCF = a × b. Here 6 × 36 = 216 = 12 × 18. It works because the shared primes are counted once in the GCF and once in the LCM — together they rebuild the full product. It also means a calculator (or a student) only ever needs one of the two: the GCF comes quickly from Euclid's algorithm — repeatedly replace the larger number by the remainder of division, 18 mod 12 = 6, 12 mod 6 = 0, so GCF = 6 — and the LCM follows by dividing the product. With three or more numbers the identity breaks (primes shared by all three get tangled), which is why this tool computes LCMs of lists by folding the two-number rule across them one pair at a time.

These are not school-only objects. The LCM is the least common denominator — adding 1/12 and 1/18 needs 36ths (3/36 + 2/36 = 5/36) — and the answer to every "two cycles, when do they coincide?" problem: buses every 12 and 18 minutes leave together every 36. The GCF is the simplifier — 12/18 reduces by 6 to 2/3 — and the equal-grouping answer: 12 juniors and 18 seniors form the largest equal mixed groups of 6. When the GCF comes out as 1 the numbers are coprime — 8 and 15, both composite, sharing nothing — and their LCM is just their product.

Euclid's algorithm, walked through once

For numbers too big to factorize comfortably, Euclid's 2,300-year-old method finds the GCF with nothing but division remainders. Take 1071 and 462. Divide the larger by the smaller and keep the remainder: 1071 = 2 × 462 + 147. Now repeat with 462 and 147: 462 = 3 × 147 + 21. Again with 147 and 21: 147 = 7 × 21 + 0. The last non-zero remainder, 21, is the GCF — and indeed 1071 = 21 × 51 and 462 = 21 × 22, with 51 and 22 sharing nothing further. The LCM then follows from the product rule: 1071 × 462 ÷ 21 = 23,562. The method works because any common divisor of the two numbers must also divide their remainder, so the problem shrinks at every step without losing the answer — the same reason it is still the algorithm inside this page and inside most software.

Worked examples

12 and 18. Factorizations 2² × 3 and 2 × 3² → GCF 6, LCM 36. Check: 12 × 18 = 216 = 6 × 36 ✓.

Three numbers: 4, 6, 8. 4 = 2², 6 = 2 × 3, 8 = 2³ → shared at lowest power: 2 → GCF 2; all at highest: 2³ × 3 = LCM 24. (Three buses every 4, 6 and 8 minutes coincide every 24.)

Coprime: 8 and 15. 2³ and 3 × 5 share nothing → GCF 1, LCM 120 — the product itself.

Methods compared

MethodHow it worksBest for
Prime factorizationCompare prime powers, as aboveUnderstanding; small numbers; 3+ numbers
Euclid's algorithmRepeated remainders until 0Large numbers; computers
Listing multiples/factorsWrite lists, find first match / largest sharedVery small numbers; teaching the idea
Product ÷ GCFLCM = a × b ÷ GCFExactly two numbers, GCF known

Frequently asked questions

What are the LCM and GCF of 12 and 18?

The GCF is 6 — the largest number dividing both (12 = 2² × 3, 18 = 2 × 3², shared primes at their lowest powers: 2 × 3 = 6). The LCM is 36 — the smallest number both divide into (all primes at their highest powers: 2² × 3² = 36). Check: 12 × 18 = 216 = 6 × 36.

Are GCF, GCD and HCF the same thing?

Yes. Greatest common factor, greatest common divisor and highest common factor are three names for one number — the largest integer that divides all the given numbers exactly. Different countries and textbooks prefer different names; the mathematics is identical.

What is the relationship between LCM and GCF?

For two numbers, LCM × GCF = the product of the two numbers. So if you know one, the other is a division away: LCM(12, 18) = 12 × 18 ÷ GCF(6) = 36. This shortcut works only for exactly two numbers, not three or more.

What is the LCM or GCF if the numbers share no factors?

Numbers with no common prime factors are called coprime or relatively prime — like 8 and 15. Their GCF is 1, and their LCM is simply their product (120). A GCF of 1 does not mean either number is prime: 8 and 15 are both composite, they just share nothing.

Where are LCM and GCF actually used?

The LCM is the least common denominator for adding fractions (thirds and quarters meet at twelfths), the meeting point of repeating schedules, and the gear-tooth alignment point in machinery. The GCF simplifies fractions to lowest terms (12/18 = 2/3 by dividing through by 6) and sizes equal groups — the largest team size that splits two classes evenly.

Note: LCM and GCF are defined for whole numbers. Zero is a special case (every number divides 0, so LCM with 0 is 0 and GCF(0, n) = n); this calculator works with positive integers, which covers the overwhelming majority of real uses.

Related tools

Definitions and examples last verified: 23 November 2026. Everything is calculated in your browser — nothing you type is sent anywhere.