Skip to main content

GCD & LCM Calculator

Find the greatest common divisor (GCD/HCF) and least common multiple (LCM) of a list of integers, with an optional step-by-step Euclidean-algorithm walkthrough.

Input

Output

Was this helpful?

Guides

The GCD & LCM Calculator finds the greatest common divisor (also called the GCD, greatest common factor, or highest common factor / HCF) and the least common multiple (LCM) of any list of whole numbers. Enter two or more integers and it returns both results instantly, with an optional step-by-step walkthrough of the Euclidean algorithm so you can check the working, not just the answer.

It is built for students learning number theory, teachers preparing worked examples, and anyone reducing fractions, finding common denominators, or scheduling repeating events.

How to use it

  1. Type your numbers into the Numbers box, separated by commas, spaces, or newlines — for example 12, 18, 24.
  2. Read the GCD and LCM results as they update.
  3. Tick Show calculation steps to reveal the full Euclidean-algorithm trace for the GCD and the LCM(a, b) = |a × b| / GCD(a, b) derivation for the LCM.

Negative numbers are accepted and treated by their absolute value, matching the standard mathematical definition. Because the calculator uses arbitrary-precision integer arithmetic, it stays exact even with very large numbers where ordinary floating-point math would drift.

What is the GCD?

The greatest common divisor of a set of integers is the largest positive integer that divides every one of them without a remainder. For 12 and 18, the GCD is 6. It is the tool you reach for when reducing a fraction to lowest terms.

What is the LCM?

The least common multiple is the smallest positive integer that every number in the set divides into evenly. For 12 and 18, the LCM is 36. It is what you need to find a common denominator or to work out when two repeating cycles line up again.

How are they calculated?

The GCD is computed with the Euclidean algorithm: repeatedly replace the larger number with the remainder of dividing it by the smaller, until the remainder is zero. For more than two numbers, the GCD is taken pairwise across the list. The LCM of a pair is derived from the GCD using LCM(a, b) = |a × b| / GCD(a, b), then extended across the whole list. Turn on Show calculation steps to see each division written out.

Why is the LCM zero when I include 0?

Zero is a multiple of every integer, so the least common multiple of any set that contains 0 is 0. The GCD of a number and 0 is simply that number.

Privacy

This calculator runs entirely in your browser. Your numbers are never uploaded, logged, or stored — the computation happens locally on your device.

gcdhcflcmeuclideangreatest common divisorleast common multiplemath

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.