KitQuarter

LCM & GCD Calculator: Least Common Multiple & Greatest Common Divisor

Enter two or more whole numbers separated by commas and this free LCM and GCD calculator returns their least common multiple and greatest common divisor — with the prime factorization of every number and each step of the working shown.

At least 2 whole numbers, each between 1 and 1,000,000,000,000. Negatives are treated as their absolute value.

KQ
Reviewed by the KitQuarter Editorial Team
Formulas verified against standard references. Calculator logic tested with verified worked examples. Last reviewed: October 2026. Our methodology

How LCM and GCD are calculated

Three equivalent routes reach the same answer — the calculator uses all of them and shows the working:

  • Prime factorization: factor every number, take the highest power of each prime that appears, and multiply. For the GCD, take the lowest power of each prime shared by all numbers instead.
  • GCD-first identity: LCM(a, b) = |a × b| ÷ GCD(a, b) — fast for two numbers once the GCD is known.
  • Pairwise: LCM(a, b, c) = LCM(LCM(a, b), c) — fold any length of list down two numbers at a time. The GCD comes from the Euclidean algorithm: GCD(a, b) = GCD(b, a mod b), repeating until the remainder is 0.
NumbersLCMGCD
8, 12244
6, 10302
12, 30606
5, 7351
6, 8, 12242

If any number in the list is 0, the LCM is 0 by definition — there is no smaller positive multiple shared with 0. Zeros are skipped when computing the GCD.

Worked example

Find the LCM and GCD of 12, 18 and 24.

Factor each: 12 = 2² × 3, 18 = 2 × 3², 24 = 2³ × 3. LCM: highest powers of each prime — 2³ (from 24) and 3² (from 18) — so LCM = 2³ × 3² = 8 × 9 = 72. GCD: lowest powers of the primes shared by all three — 2¹ (from 18) and 3¹ (from 12 or 24) — so GCD = 2 × 3 = 6. Check: 72 ÷ 12 = 6, 72 ÷ 18 = 4, 72 ÷ 24 = 3 (all whole), and 12 ÷ 6 = 2, 18 ÷ 6 = 3, 24 ÷ 6 = 4 (all whole).

How to use the LCM and GCD calculator

Type the numbers exactly as you would say them — commas or spaces both work.

Step by step

  1. Enter at least two whole numbers. Separate them with commas or spaces, e.g. 12, 18, 24.
  2. Press Calculate. The LCM and GCD appear at the top of the results.
  3. Read the factorizations. Each number's prime factorization is printed in a table.
  4. Follow the highest powers. The working shows which prime powers were kept for the LCM and which for the GCD.
  5. Copy the working. The steps are written out so they double as a study aid for homework.
3D illustration of the numbers 12, 18 and 24 converging through prime factors to LCM 72, labeled LCM and GCD Calculator
One input, two answers: the least common multiple and the greatest common divisor.

LCM vs. GCD: what each one tells you

The two answers solve opposite problems. The LCM looks upward for the first number every input divides into evenly; the GCD looks downward for the biggest number that divides every input evenly.

LCM (least common multiple)GCD (greatest common divisor)
Answers the questionWhat is the smallest number all of these divide into?What is the largest number that divides all of these?
Size vs. inputsAlways at least the largest inputNever larger than the smallest input
Coprime inputs (e.g. 5, 7)Equals the product (35)Equals 1
Main classroom useCommon denominators for fractionsSimplifying fractions

The fraction connection is the one you will use most: the LCM of two denominators is their least common denominator, and dividing numerator and denominator by their GCD reduces a fraction to lowest terms — a fraction calculator handles both operations directly.

Factor trees for 12, 18 and 24 showing prime factorization steps: 12 equals 2 squared times 3, 18 equals 2 times 3 squared, 24 equals 2 cubed times 3
Break each number into primes, then take the highest power of each.

Prime factorization: the method that always works

Listing multiples works for small numbers but gets long fast; factorization scales. For 12, 18 and 24 the exponent table is:

PrimeHighest powerFrom which number
22³24
33²18

LCM = 2³ × 3² = 72. For the GCD the same table flips to lowest powers of the primes every number shares: 2¹ × 3¹ = 6. This highest-power / lowest-power symmetry is why one factorization answers both questions at once.

Factorization shows up everywhere in number theory — if you enjoy this kind of counting, a permutation and combination calculator puts the same systematic thinking to work on arrangements and selections.

Where the LCM shows up: fractions, schedules and cycles

The LCM is a scheduling number — it answers "when do these cycles line up again":

  • Fractions: to add 1/12 + 1/18, the LCM of the denominators (36) is the least common denominator: 3/36 + 2/36 = 5/36.
  • Repeating schedules: two buses leaving every 12 and 18 minutes depart together every 36 minutes.
  • Gears and cycles: meshed gears with 12 and 18 teeth return to the same alignment every 36 teeth.
  • Calendar repeats: events on different cycles coincide after the LCM of their periods.

Whenever a problem asks for the first time several repeating things happen together, reach for the LCM; whenever it asks for the biggest thing several quantities share, reach for the GCD.

3D render of an abacus and chalkboard showing GCD equals 6 and LCM equals 72
Factorization is the study-friendly route to the answer.

Frequently asked questions

What is the LCM of 12 and 18?

36. Prime factorizations: 12 = 2² × 3 and 18 = 2 × 3². Take the highest power of each prime: 2² × 3² = 4 × 9 = 36.

What is the difference between LCM and GCD?

The LCM is the smallest number divisible by all inputs; the GCD is the largest number dividing all inputs. For 12 and 18: LCM = 36, GCD = 6.

How do you find the LCM of three or more numbers?

Either pairwise — LCM(a, b, c) = LCM(LCM(a, b), c) — or by prime factorization: take the highest power of every prime across all numbers and multiply.

What is the GCD of 12 and 18?

6. Common prime factors at their lowest powers: 2 × 3 = 6. Equivalently, the Euclidean algorithm: 18 mod 12 = 6, 12 mod 6 = 0.

Can the LCM be smaller than the numbers I enter?

No — the LCM is always at least as large as the biggest input. When the numbers share no common factor, the LCM is simply their product (for example, 7 and 5 give 35).

Do I need to factor the numbers myself?

No — the calculator prints each number's prime factorization and the highest-power working automatically, so the steps double as a study aid.

What if I enter a zero or a negative number?

Negatives are treated as their absolute value. If any number is zero, the LCM is 0 by definition; zeros are skipped when computing the GCD.