LCM and GCD Calculator
Type two or more whole numbers to get their greatest common divisor, also called the highest common factor, and their least common multiple. The page shows every division of the Euclidean algorithm, how the LCM is built up pair by pair, and the prime factorisation of each number so you can check the answer the way it is taught in school.
Find the GCD and LCM
Result
Formula and working
How to Use the LCM and GCD
- Enter the numbers separated by commas or spaces.
- Press Calculate.
- Read the GCD and LCM, then follow the Euclidean algorithm and prime factor table.
About This Tool
Pupils simplifying fractions or finding common denominators, teachers, and programmers or puzzle-solvers working with cycles and gear ratios.
Input: Whole numbers · Output: GCD and LCM.
Features and Limitations
Features
- Works with up to 20 numbers and very large integers (exact BigInt arithmetic).
- Step-by-step Euclidean algorithm.
- Prime factorisations for numbers up to 10^12.
- Says whether the numbers are coprime.
Limitations
- Whole numbers only; decimals and fractions are rejected.
- Negative numbers are treated as their absolute values, and an LCM involving 0 is reported as 0.
- Numbers above 10^12 are not factorised (their GCD and LCM are still exact).
- Results are computed in your browser; nothing you enter is sent to a server.
Example
For 12, 18 and 30: gcd(12, 18) = 6 and gcd(6, 30) = 6, so the GCD is 6. lcm(12, 18) = 36 and lcm(36, 30) = 180, so the LCM is 180.
Frequently Asked Questions
Are GCD, GCF and HCF the same thing?
Yes. Greatest common divisor, greatest common factor and highest common factor are three names for the largest number that divides all the given numbers exactly.
How does the Euclidean algorithm work?
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.
How are GCD and LCM related?
For two positive numbers, GCD × LCM = a × b. So lcm(a, b) = a × b ÷ gcd(a, b).
What does coprime mean?
Two numbers are coprime when their GCD is 1, for example 8 and 15, even though neither is prime.
Related Tools
More like this: all Math tools, all Calculators tools or the TinySandy home page.