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
Out
Greatest common divisor
6
LCM 180
| Number | Prime factors |
|---|---|
| 12 | 2² × 3 |
| 18 | 2 × 3² |
| 30 | 2 × 3 × 5 |
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
Related tools
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