LCM & GCD Calculator

Find the least common multiple and greatest common divisor of integers.

Enter your values

Change any field. The result is recalculated on this device.

Formula, example and assumptions
Greatest common divisor6

Your result

Local calculation
Greatest common divisor6

The GCD is the largest positive whole number that divides every entry exactly. The LCM is their least common multiple; an entered zero makes the LCM zero.

Whole numbers
12, 18, 24
See how this is calculated

Result breakdown

Least common multiple
72
Check the inputs and method

These are your current inputs, not the worked example further down the page.

Whole numbers
12, 18, 24

Method

Euclidean step: gcd(a,b) = gcd(b, a mod b), ending at gcd(a,0) = |a|. For nonzero a and b, lcm(a,b) = |ab|/gcd(a,b). Apply each operation across the whole list.

Read the worked example and assumptions

How this calculation works

The greatest common divisor is the largest positive integer that divides every entered number. The least common multiple is the smallest positive shared multiple for nonzero inputs. Use the GCD to simplify integer proportions and the LCM to align repeating cycles with whole-number periods.

Euclidean step: gcd(a,b) = gcd(b, a mod b), ending at gcd(a,0) = |a|. For nonzero a and b, lcm(a,b) = |ab|/gcd(a,b). Apply each operation across the whole list.

Worked example

This example uses illustrative inputs. Your current result is shown above.

For 12, 18 and 24, gcd(12,18) = 6 and gcd(6,24) = 6. lcm(12,18) = 36, then lcm(36,24) = 72. The outputs are GCD 6 and LCM 72.

Assumptions and limits

  • Use whole numbers within the safe input range; fractional measurements need an explicitly chosen common unit first.
  • Negative signs are ignored when finding positive divisors and multiples.
  • If some but not all inputs are zero, the LCM is zero by this tool’s convention. An all-zero list is rejected.

Questions people ask

Can I enter more than two numbers?

Yes. Each result is accumulated over the complete list, so the final GCD divides every input and the final LCM is shared by all nonzero inputs.

Why does including zero change the LCM?

This implementation uses lcm(a,0) = 0. For scheduling recurring events, use positive nonzero periods rather than treating a nonrecurring event as a zero-length cycle.

Related calculators