Skip to content

GCD and LCM Calculator

Find the greatest common divisor and least common multiple of two or more numbers, with Euclid's steps.

Result

Enter your values and select Calculate to see the result.

Runs in your browser — nothing you enter is sent to a server.

How the GCD and LCM Calculator works

Enter two or more whole numbers. The greatest common divisor (GCD, also called HCF) is the largest number that divides all of them; the least common multiple (LCM) is the smallest number they all divide into. The GCD uses Euclid's algorithm, whose steps are shown for the first two numbers, and the LCM is exact even when it's very large.

Formulas

Euclid's algorithm

gcd(a, b) = gcd(b, a mod b), until the remainder is 0

LCM

lcm(a, b) = |a × b| ÷ gcd(a, b)

Examples

48 and 18

48 = 2 × 18 + 12, 18 = 1 × 12 + 6, 12 = 2 × 6 + 0, so the GCD is 6 and the LCM is 48 × 18 ÷ 6 = 144.

12, 18 and 30

GCD 6, LCM 180.

Frequently asked questions

What are GCD and LCM used for?

Simplifying fractions (divide by the GCD) and adding fractions (use the LCM as the common denominator).

What about negative numbers?

Signs are ignored: the GCD and LCM are always positive.

Why can't I use 0?

Every number divides 0, so the LCM isn't defined with 0.

Prime Number Checker

Check whether a number is prime and see its prime factorization, divisors and the nearest primes.

Math Tools

Fraction Calculator

Add, subtract, multiply and divide fractions, with the answer simplified and shown as a mixed number and decimal.

Math Tools

Ratio Calculator

Solve a proportion for the missing value, or simplify a ratio to its lowest terms.

Math Tools