PocketCalc

LCM and GCD Calculator

Free LCM (least common multiple) and GCD (greatest common divisor) calculator — type a list of integers, get both at once. Works in your browser.

GCD = 6 · LCM = 36

Type a list of integers, separated by commas, spaces or semicolons. The calculator returns the GCD (greatest common divisor) and the LCM (least common multiple) in one shot.

Quick definitions

  • GCD(a, b, …) — the largest integer that divides every input exactly.
  • LCM(a, b, …) — the smallest positive integer that every input divides exactly.

How they’re computed

GCD uses the Euclidean algorithm:

GCD(a, b) = GCD(b, a mod b), until b = 0.

It’s fast even for huge integers. For more than two numbers we apply it pairwise — GCD(a, b, c) = GCD(GCD(a, b), c).

LCM comes from the identity

LCM(a, b) = |a × b| ÷ GCD(a, b)

and the same pairwise reduction for longer lists.

Where they come up

  • Adding fractions — the common denominator is the LCM.
  • Scheduling cycles — two events repeating every a and b days both occur every LCM(a, b) days.
  • Gear teeth and pulleys — engineering ratios.
  • Number theory — the bedrock of factorization-based proofs.

Worked examples

  • 12 and 18

    GCD = 6 · LCM = 36

  • 8, 12, 16

    GCD = 4 · LCM = 48

  • Coprime 7 and 9

    GCD = 1 · LCM = 63

Frequently asked questions

What's the difference between GCD and LCM?

GCD (greatest common divisor) is the largest integer that divides every number in the list. LCM (least common multiple) is the smallest positive integer that every number in the list divides. They sit at opposite ends of the divisibility lattice.

How does the calculator find them?

GCD is computed with the Euclidean algorithm — repeatedly replace the pair (a, b) with (b, a mod b) until b is zero; the remaining a is the GCD. For more than two numbers we apply it pairwise. LCM uses the identity LCM(a, b) = |a × b| ÷ GCD(a, b).

Why aren't decimals allowed?

GCD and LCM are defined for *integers*. For fractions or reals you'd need a different concept (or scale everything up by a common denominator first).

Why isn't zero allowed?

GCD with zero is technically the other number (so GCD(0, n) = |n|), but LCM with zero is always zero — which makes the answer uninformative and usually means a typo. We reject zero to keep both results meaningful.

What about negative numbers?

We use absolute values, since GCD and LCM are conventionally non-negative. GCD(-12, 18) = 6, same as GCD(12, 18).