RSRobince Studio

GCD & LCM Calculator

Enter two to ten whole numbers to get their greatest common divisor (also called HCF) and least common multiple, plus the prime factorisations and the Euclidean steps behind them.

Runs in your browser. Your files are never uploaded.

Loading GCD & LCM Calculator…

How to use GCD & LCM Calculator

  1. Type at least two positive whole numbers into the boxes.
  2. Press Add number for more boxes, up to ten.
  3. Read the GCD and LCM at the top.
  4. Scroll down for each number’s prime factorisation and the Euclid steps.

Two ways to find them

The Euclidean algorithm repeatedly replaces the larger number with the remainder after division until the remainder is zero; the last non-zero value is the GCD. For 48 and 180: 180 = 3 × 48 + 36, then 48 = 1 × 36 + 12, then 36 = 3 × 12 + 0, so the GCD is 12.

With prime factorisations, 48 = 2^4 × 3 and 180 = 2^2 × 3^2 × 5. The GCD takes the smallest power of each shared prime (2^2 × 3 = 12). The LCM takes the largest power of every prime that appears (2^4 × 3^2 × 5 = 720).

For more than two numbers the tool applies the pairwise rule repeatedly: gcd(a, b, c) = gcd(gcd(a, b), c), and likewise for the LCM.

Everyday uses

  • Simplifying fractions by dividing by the GCD of numerator and denominator.
  • Adding fractions by using the LCM of the denominators.
  • Scheduling: finding when two repeating events line up, such as buses every 12 and 18 minutes (LCM = 36).
  • Splitting items into the largest equal groups with nothing left over.
  • Tiling a rectangle with the largest possible square tiles.

Limits

Inputs must be positive whole numbers up to 2^53. Zero and negative numbers are rejected because the usual definitions differ for them. Prime factorisation uses trial division, so extremely large numbers with big prime factors can take a moment. All work stays in your browser. A useful sanity check: the GCD can never exceed the smallest number you entered, and the LCM can never be smaller than the largest one. If the numbers share no prime factors, the LCM of two numbers is just their product, which is why coprime pairs such as 8 and 15 give 120.

Why use this gcd & lcm calculator tool

  • Up to ten numbers. Add or remove inputs and the results update immediately.
  • Euclid steps. Every division step of the Euclidean algorithm is written as a = q × b + r.
  • Prime factorisations. See each number as a product of primes to understand why the answer is what it is.
  • Exact big results. The LCM is computed with big integers, so it never overflows even for large inputs.

Frequently asked questions

What is the difference between GCD and LCM?

The greatest common divisor is the largest number that divides all your numbers. The least common multiple is the smallest positive number that all of them divide into.

How are they related?

For two numbers, GCD × LCM = a × b. For 48 and 180 the GCD is 12 and the LCM is 720, and 12 × 720 = 8,640 = 48 × 180.

What if the GCD is 1?

The numbers are coprime (relatively prime) and the LCM is simply their product when there are only two numbers.

More free tools