GCD and LCM Calculator
Separate values with commas, spaces or new lines. Decimals are ignored.
Enter at least two integers to see the GCD and LCM.
- Numbers
- —
- Coprime
- —
Prime factorization
Euclidean algorithm
What is GCD and LCM Calculator
This calculator finds the greatest common divisor (GCD, also called HCF) and the least common multiple (LCM) of any list of integers. The GCD is the largest number that divides every value with no remainder, and the LCM is the smallest number that every value divides into. Enter two or more numbers and you also get the prime factorization of each one, and for a pair, the full working of the Euclidean algorithm.
How to use
- Type or paste two or more integers into the box.
- Separate the values with commas, spaces or new lines.
- Read the GCD and the LCM at the top.
- Check the prime factorization of each number below, plus the Euclidean steps for a pair.
When to use it
Adding fractions like 1/12 and 1/18 and stuck on a common denominator? Enter 12 and 18 to get an LCM of 36 (the lowest common denominator) and a GCD of 6 for reducing the result. The same two numbers cover class homework, gear and pulley ratios, and lining up repeating schedules that only match every LCM units.
Frequently asked questions
What is the difference between GCD and LCM?
The GCD (greatest common divisor, or HCF) is the largest integer that divides all your numbers exactly. The LCM (least common multiple) is the smallest positive integer that all your numbers divide into. For 12 and 18 the GCD is 6 and the LCM is 36.
How is the GCD calculated?
This tool uses the Euclidean algorithm: divide the larger number by the smaller, replace the larger with the remainder, and repeat until the remainder is 0. The last non-zero divisor is the GCD. For more than two numbers it applies the same step pairwise.
What happens if I enter 0?
The GCD ignores zeros the way maths does (the GCD of 0 and a number is that number), but the LCM becomes 0 whenever any value is 0, since nothing is a common multiple of 0 and a positive number. The tool flags this.
Can I share this tool with my numbers pre-filled?
Yes. The URL updates automatically as you type. Copy it from the address bar or use the Share button, and anyone who opens the link will see your exact numbers ready to go.
Related tools
A-a Gradient Calculator
Calculate the alveolar-arterial oxygen gradient from FiO2, PaO2 and PaCO2, and compare it to the expected value for age. Free and instant.
How Old Am I? Age Calculator
Find out exactly how old you are with this free age calculator. Enter your date of birth and get your age in years, months, days, zodiac sign, and more.
Anion Gap Calculator
Calculate the serum anion gap from sodium, chloride and bicarbonate, with optional potassium and albumin correction, to screen for metabolic acidosis.