An LCM and GCD calculator takes a list of whole numbers. The greatest common divisor (GCD, also called HCF or GCF) is the largest number that divides all of them exactly. The least common multiple (LCM) is the smallest number that all of them divide into exactly. Both are found with Euclid's algorithm.
How to use the LCM and GCD Calculator
- Enter your numbersType two or more positive whole numbers separated by commas or spaces.
- Read the LCM and GCDBoth answers appear at once and can be copied with one click.
- Check the factor tableThe table lists the prime factorisation of every number and of the two results, so you can see where the answers come from.
How the LCM and GCD are found
This LCM and GCD calculator uses Euclid's algorithm for the greatest common divisor: replace the larger number by the remainder of dividing it by the smaller one, and repeat until the remainder is zero. The last non-zero number is the GCD. For 18 and 12: 18 mod 12 = 6, then 12 mod 6 = 0, so the GCD is 6.
The least common multiple follows from the identity LCM(a, b) = a × b ÷ GCD(a, b). For 12 and 18 that is 216 ÷ 6 = 36. With more than two numbers the tool works through the list pair by pair: GCD(12, 18, 30) = GCD(GCD(12, 18), 30) = 6, and LCM(12, 18, 30) = LCM(36, 30) = 180.
The prime factor table shows the same thing another way. 12 = 2² × 3, 18 = 2 × 3² and 30 = 2 × 3 × 5. The GCD takes the lowest power of each prime that appears in every number (2 × 3 = 6). The LCM takes the highest power of every prime that appears anywhere (2² × 3² × 5 = 180).
When you need them
- Simplifying fractions: divide the numerator and denominator by their GCD. 18/30 becomes 3/5.
- Adding fractions: the least common denominator is the LCM of the denominators. The fraction calculator does this for you.
- Repeating events: two buses leaving every 12 and 18 minutes line up again after LCM(12, 18) = 36 minutes.
- Equal groups: the GCD is the largest group size that divides several quantities with nothing left over.
GCD, HCF (highest common factor) and GCF (greatest common factor) are three names for the same thing. Numbers whose GCD is 1, such as 8 and 15, are called coprime, and their LCM is simply their product. Zero is not accepted, because every number divides zero. Results are exact up to 9,007,199,254,740,991; if an LCM would be larger than that, the tool says so rather than showing a rounded figure. To test a single number, use the prime number checker.
Frequently asked questions
What is the difference between LCM and GCD?
The GCD is the largest number that divides every number in the list. The LCM is the smallest number that every number in the list divides into. For 4 and 6 the GCD is 2 and the LCM is 12.
Is HCF the same as GCD?
Yes. Highest common factor (HCF), greatest common factor (GCF) and greatest common divisor (GCD) all mean the same value. The name depends on where you went to school.
How do I find the LCM of three numbers?
Find the LCM of the first two, then the LCM of that result and the third number. The LCM and GCD calculator does this automatically for up to 50 numbers.
What does it mean if the GCD is 1?
The numbers share no prime factor and are called coprime or relatively prime. Their least common multiple is then the product of the numbers.
Can I enter negative numbers or decimals?
Negative numbers are treated as positive, since divisors and multiples are compared by size. Decimals are rejected, because LCM and GCD are defined only for whole numbers.
Last updated 24 November 2026 by the TheTechFolk team.