GCD & LCM Calculator

Greatest common divisor and least common multiple of two integers.

Quick answer

  • Formula: GCD(a, b) × LCM(a, b) = a × b, so LCM = (a × b) ÷ GCD
  • Worked example — Greatest common divisor (GCD): 6 (full example below).

GCD & LCM Calculator

Worked example result
Greatest common divisor (GCD)6
Least common multiple (LCM)36
Product (a × b)216

For 12 and 18: the GCD is 6 and the LCM is 36. Check the identity: 6 × 36 = 216, and 12 × 18 = 216.

The greatest common divisor (GCD) is the largest number that divides both of your numbers exactly — for 12 and 18 it is 6. The least common multiple (LCM) is the smallest number that both of them divide into — for 12 and 18 it is 36.

The two are linked by a neat identity: GCD × LCM = a × b. GCD is the key to simplifying fractions, and LCM is how you find a common denominator for adding fractions or work out when repeating events coincide.

The formula

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

Worked example

For 12 and 18: the GCD is 6 and the LCM is 36. Check the identity: 6 × 36 = 216, and 12 × 18 = 216.

The example is pre-loaded in the result panel — press Calculate with your own numbers to replace it.

Frequently asked questions

How is GCD calculated quickly for large numbers?

By Euclid's algorithm: repeatedly replace the larger number with the remainder of dividing the two, until the remainder is zero. GCD(48, 18): 48 mod 18 = 12, 18 mod 12 = 6, 12 mod 6 = 0 — so the GCD is 6.

When would I actually use the LCM?

When two cycles must line up: buses leaving every 12 and every 18 minutes coincide every 36 minutes (the LCM). It is also the least common denominator when adding fractions like 1/12 + 1/18.

What if the two numbers share no factors?

Then the GCD is 1 (the numbers are called coprime) and the LCM is simply their product — for example GCD(7, 5) = 1 and LCM(7, 5) = 35.

Category: Math calculators

Sources & methodology

This calculator applies the formula shown on this page exactly as written, using the standard definitions for its inputs. Results are computed from the values you enter — no data is stored — and are rounded only for display.

Content last reviewed by CalcHub Editorial.

Embed this calculator on your site

Free to use with attribution — paste the snippet below and the calculator appears on your page, with a link back to CalcHub.

<iframe src="https://calculator-site-57a.pages.dev/embed/gcd-lcm-calculator" width="100%" height="640" style="border:1px solid #d9e2ea;border-radius:12px" loading="lazy" title="GCD & LCM Calculator — CalcHub"></iframe>

Open the embed version →