Math · free · step by step
GCD and LCM Calculator
Find the greatest common divisor (GCD, HCF) and least common multiple (LCM) of two or more numbers, with prime factors and Euclid’s algorithm step by step.
Step by step
Worked examples
GCD and LCM examples
| Numbers | GCD | LCM |
|---|---|---|
| 12, 18 | 6 | 36 |
| 8, 12 | 4 | 24 |
| 24, 36 | 12 | 72 |
| 15, 25 | 5 | 75 |
| 14, 21 | 7 | 42 |
| 16, 40 | 8 | 80 |
| 45, 60 | 15 | 180 |
| 12, 18, 30 | 6 | 180 |
| 24, 36, 60 | 12 | 360 |
| 1071, 462 | 21 | 23,562 |
More math
Other math tools
- Scientific CalculatorTrig, logs, powers, n!, nCr with history and exact answers
- Fraction CalculatorAdd, subtract, multiply and divide fractions with steps
- Matrix CalculatorDeterminant, inverse, multiply and RREF with steps
- Statistics CalculatorMean, median, mode, standard deviation and regression
- Binary ConverterBinary, decimal, hex and octal with steps
- Complex Number Calculatora + bi, polar form, powers and roots with steps
- Normal Distribution CalculatorNormal curve probabilities, z-scores and inverse normal
- Binomial Distribution CalculatorP(X = k), P(X ≤ k) and more for n trials
- Poisson Distribution CalculatorProbabilities of counts with average rate λ
- Prime Factorization CalculatorPrime factors, factor trees and divisors of any number
- Permutation and Combination CalculatorPermutations and combinations, exact, with steps
- Significant Figures CalculatorCount, round and calculate with significant figures
- Equation SolverQuadratic, cubic and simultaneous equations with steps
- Graphing CalculatorPlot functions, circles, polar and parametric curves
- Derivative CalculatorDerivatives with every step shown
- Integral CalculatorIntegrals with steps, definite and indefinite
- Ohm’s Law CalculatorVolts, amps, ohms and watts
Questions
GCD and LCM Calculator FAQ
Free, private and works offline: everything is worked out in your browser.
How do you find the GCD (greatest common factor)?
Write each number as a product of primes and multiply the primes they share, each with its lowest power. 12 = 2² × 3 and 18 = 2 × 3², so GCD = 2 × 3 = 6. It is also called the HCF (highest common factor) or GCF.
How do you find the LCM (least common multiple)?
Take every prime that appears in any of the numbers, with its highest power: LCM(12, 18) = 2² × 3² = 36. For two numbers you can also use LCM = a × b ÷ GCD = 12 × 18 ÷ 6 = 36.
What is Euclid’s algorithm?
Divide the larger number by the smaller and keep the remainder; repeat with the smaller number and the remainder until the remainder is 0. The last non-zero remainder is the GCD: 1071 = 2 × 462 + 147, 462 = 3 × 147 + 21, 147 = 7 × 21 + 0, so GCD(1071, 462) = 21. It works quickly even for huge numbers.
What does co-prime mean?
Two numbers are co-prime (relatively prime) when their GCD is 1, so they share no prime factor, like 8 and 15. Their LCM is then just their product: 120.
When do I use GCD and LCM?
Use the GCD to simplify fractions (18/24 ÷ 6 = 3/4) and to split things into the largest equal groups. Use the LCM to find a common denominator and for “when will they line up again” problems, such as buses every 12 and 18 minutes meeting every 36 minutes.
Can it do more than two numbers?
Yes, up to 20 numbers at once, separated by commas or spaces, with the prime factor table and Euclid’s steps for each pair.