GCD & LCM Calculator

The GCD and LCM calculator finds the greatest common divisor (also called the highest common factor, HCF) and the least common multiple of two or more whole numbers. It shows every step of Euclid's algorithm and the prime factorization of each number, so you can follow the working. It handles numbers of any size, in your browser.

Example: 48 and 18

StepWorking
148 = 2 × 18 + 12
218 = 1 × 12 + 6
312 = 2 × 6 + 0 → GCD 6
LCM48 × 18 / 6 = 144

When to use it

  1. Simplify fractions using the GCD.
  2. Find a common denominator with the LCM.
  3. Check number theory homework.
  4. Work out when repeating events line up.

How to Use

  1. Enter two or more whole numbers.
  2. Read the GCD and LCM.
  3. Follow the Euclid steps and prime factorizations.

Features

  1. GCD / HCF and LCM
  2. Any number of inputs
  3. Euclid's algorithm steps
  4. Prime factorizations
  5. Big-integer exact
  6. 100% client-side

FAQs

What is the GCD?

The largest number that divides all the numbers exactly. GCD(12, 18) = 6.

Is GCD the same as HCF?

Yes — greatest common divisor and highest common factor are two names for the same thing.

How do you find the LCM?

Divide the product of two numbers by their GCD: LCM(12, 18) = 216 ÷ 6 = 36.

Can I enter more than two numbers?

Yes, as many as you like, separated by commas or spaces.

Is anything uploaded?

No. It runs in your browser.

Technical Details

The greatest common divisor is found with Euclid's algorithm — repeatedly replacing (a, b) with (b, a mod b) until the remainder is zero — and each division step is shown. For more than two numbers the GCD is applied pairwise: gcd(a, b, c) = gcd(gcd(a, b), c). The least common multiple uses lcm(a, b) = |a × b| ÷ gcd(a, b), also applied pairwise. All arithmetic uses big integers, so numbers of any size are exact. Each number's prime factorization is shown as well, factored with trial division by small primes, Miller–Rabin primality testing and Pollard's rho, which is how the GCD (lowest powers of shared primes) and LCM (highest powers of all primes) can be checked by hand.

Calculators & Converters

Calculators & Converters

  • Matrix Calculator
  • Prime Number Checker
  • Ratio & Proportion Calculator
  • Roman Numeral Converter
  • Rounding Calculator
  • Scientific Notation Converter
  • Number Sequence Generator
  • Data Size Converter