Finance 44 tools → Date 19 tools → Health 27 tools → Everyday 23 tools → Math 19 tools → Construction 16 tools → PDF 23 tools → Education 10 tools → Conversion 7 tools → Text 12 tools → Image 8 tools → About → Contact →

LCM and GCF Calculator

Runs entirely in your browser — your numbers are never sent anywhere.

LCM
—

Detail

Prime factorization

Two questions about how numbers share factors

Enter two, three or four whole numbers and this calculator answers the two sharing questions that run through fractions, gears, timetables and tiling. The greatest common factor (GCF, also called the greatest common divisor, GCD, or highest common factor, HCF) is the largest number that divides every one of your numbers exactly. The lowest common multiple (LCM) is the smallest positive number that every one of your numbers divides into exactly. They sound like mirror images, and they are: one looks downwards at shared divisors, the other upwards at shared multiples, and for two numbers they are locked together by the elegant fact that LCM × GCF equals the product of the two numbers themselves.

The everyday homes of these ideas are worth naming, because they explain why both are taught. Adding fractions needs a common denominator, and the least one — the LCM of the denominators — keeps the arithmetic smallest; that is the same machinery the Fraction Calculator uses under the hood. Simplifying a fraction divides top and bottom by their GCF. Two buses leaving a station every 12 and every 18 minutes next depart together after their LCM, 36 minutes. Two gears, a pattern of tiles, a pair of blinking lights — whenever cycles must coincide or quantities must be shared with nothing left over, one of these two numbers is the answer.

Prime factorisation: the method that explains both

GCF: shared primes, each at its LOWEST power  ·  LCM: all primes, each at its HIGHEST power

Write each number as a product of primes — 12 is 22 × 3 and 18 is 2 × 32 — and both answers fall out of the same picture, shown line by line in the panel below the calculator. The GCF takes only the primes appearing in every factorisation, each at the smallest exponent it has anywhere: here 21 × 31 = 6. The LCM takes every prime that appears at all, each at the largest exponent it has anywhere: 22 × 32 = 36. Lowest shared powers down, highest powers up — that single sentence is the whole method, for any count of numbers.

The Euclidean shortcut for the GCF

Factorising is illuminating but slow for large numbers, and the GCF has a famous shortcut over two thousand years old: Euclid's algorithm. Divide the larger number by the smaller and keep only the remainder; then repeat with the smaller number and that remainder; when a remainder of zero appears, the last non-zero remainder is the GCF. The remainders shrink relentlessly, so even enormous numbers resolve in a handful of steps, and this page folds that algorithm across your numbers — GCF of the first two, then GCF of that result with the third, and so on. The LCM then uses the identity LCM(a, b) = a × b ÷ GCF(a, b), folded the same way, dividing before multiplying so intermediate numbers stay as small as possible.

Edge cases handled honestly

Signs are ignored — the GCF and LCM of −12 and 18 are the same as for 12 and 18, because divisibility does not care about sign. Decimals are truncated to whole numbers, since common factors and multiples are whole-number ideas. Zero is the one genuine special case: every number divides zero, so a zero among your inputs leaves the GCF to be decided by the other numbers, while the only common multiple involving zero is zero itself, which makes the LCM 0 — the page notes this rather than quietly hiding it. And if you enter more than four numbers, the first four are used and the note tells you so.

Worked example

For 12 and 18: the GCF is 6 (the largest number dividing both) and the LCM is 36 (the smallest number both divide into). Check: 6 × 36 = 216 = 12 × 18. Add 24 and the LCM becomes 72 while the GCF stays 6.

How to use this calculator

  1. Type two to four whole numbers separated by commas, such as 12, 18.
  2. Read the LCM in the green panel and the GCF in the breakdown.
  3. For two numbers, check LCM x GCF against the product of your numbers.
  4. Read the prime factorisation of each number in the panel below.
  5. Use the GCF to simplify fractions and the LCM to find common denominators or coinciding cycles.

GCF, GCD, HCF — why one idea has three names

Depending on the textbook and the country, the same number is called the greatest common factor, the greatest common divisor, or the highest common factor. Factor and divisor both name a number that divides another exactly, and greatest and highest are making the same claim, so all three labels describe the identical calculation and the identical answer. LCM is more consistent worldwide — lowest or least common multiple — possibly because there was less room for variation. Whichever name your course or workplace uses, the prime-factorisation picture below the calculator is the shared explanation underneath all of them.

Frequently asked questions

What is the difference between LCM and GCF?
The GCF is the largest number that divides all your numbers exactly — it is never bigger than the smallest of them. The LCM is the smallest number that all your numbers divide into — it is never smaller than the largest of them.
How do you find the LCM and GCF from prime factorisation?
For the GCF, take the primes shared by every number, each at its lowest power. For the LCM, take every prime that appears, each at its highest power. 12 and 18 give GCF 6 and LCM 36 this way.
Why does LCM times GCF equal the two numbers multiplied together?
Every prime factor is counted once across the pair: the GCF takes its lower power and the LCM its higher power, so together they account for exactly the factors of both numbers. This identity holds for two numbers, not in general for three or more.
Keep going

Related math calculators