Skip to content
Sumly

GCD & LCM Calculator

Greatest common divisor and least common multiple of any list of numbers.

In

Separate with commas or spaces, such as 12, 18, 30

The GCD (also called the HCF) is the largest number that divides all of them. The LCM is the smallest number all of them divide into.

Out

Greatest common divisor

6

LCM 180

Least common multiple180
Coprime (GCD is 1)No
NumberPrime factors
122² × 3
182 × 3²
302 × 3 × 5
GCD keeps only the primes every number shares, at their lowest power. LCM takes every prime that appears, at its highest power.

How the GCD and LCM calculation works

Each number is split into prime factors. The greatest common divisor multiplies the primes that every number shares, each at its lowest power. The least common multiple multiplies every prime that appears, each at its highest power.

In practice the GCD is found with Euclid's algorithm, which repeatedly replaces the larger number with the remainder of dividing it by the smaller. The LCM of each pair is a × b ÷ GCD, carried across the list.

The LCM is computed with exact big integers, so it stays correct even when it grows far beyond the numbers you entered.

Worked example

For 12, 18 and 30, the factorisations are 2² × 3, 2 × 3² and 2 × 3 × 5. The shared primes at their lowest powers give 2 × 3 = 6, the GCD. Every prime at its highest power gives 2² × 3² × 5 = 180, the LCM.

The tool above opens with these numbers. Change them to run your own scenario, or press Reset to come back to this example.

Frequently asked questions

Check whether a number is prime and break it into prime factors.

A plain calculator that you can type into, with a running history.

Trig, logs, powers, roots and factorials, in degrees or radians.

Three percentage questions, answered instantly.

How far apart two values are, when neither is the starting point.

Solve a proportion for the missing value, or simplify a ratio.

  • gcd
  • lcm
  • hcf
  • greatest common factor
  • least common multiple
  • math