Euclidean algorithm · Steps shown

LCM & GCD Calculator

The least common multiple and greatest common divisor of two numbers — computed with Euclid's algorithm, steps included.

GCD — greatest common divisor

6

largest number dividing both 12 and 18

LCM — least common multiple

36

smallest number both divide into evenly

Euclidean algorithm steps

  1. 118 = 1 × 12 + 6
  2. 212 = 2 × 6 + 0

The last non-zero remainder is the GCD: 6. Then LCM = (12 × 18) ÷ 6 = 36.

What you can do with them

  • Reduce a fraction: 12/18 simplifies to 2/3 — divide top and bottom by the GCD.
  • Add fractions: the LCM 36 is the smallest common denominator for denominators 12 and 18.
  • Syncing cycles: events repeating every 12 and 18 units coincide every 36 units.

Euclid, 300 BC

Repeatedly replace the larger number with the remainder of dividing by the smaller. Over two thousand years old and still the fastest way to find a GCD.

Coprime pairs

A GCD of 1 means the numbers are coprime — they share no factors. Coprime pairs are the foundation of RSA encryption and many scheduling tricks.

Check: LCM × GCD = a × b

This identity always holds for positive integers — a built-in sanity check on any LCM/GCD answer, and the exact formula this tool uses.

How to use the LCM & GCD calculator

  1. Enter two numbers

    Positive whole numbers up to a trillion — decimals are rounded down, negatives take their absolute value.

  2. Read both answers

    GCD and LCM appear side by side, with a note when the numbers are coprime.

  3. Follow Euclid's steps

    Each division-with-remainder step is listed, ending at the last non-zero remainder — the GCD.

  4. Apply them

    Use the GCD to reduce fractions and the LCM as a common denominator or cycle-sync point.

Whole numbers only — for fraction or decimal inputs, scale them to integers first.

Frequently asked questions

Related tools

Need a custom tool?

We build calculators and internal tools for businesses — get in touch.

Directory last updated 2 December 2026.

Disclaimer: inputs are treated as whole numbers — decimals are truncated and results are exact only within JavaScript's safe-integer range (up to 9 × 10¹⁵).