LCM and HCF Calculator
Find the LCM and HCF (GCD) of two numbers.
Was this tool helpful?
Thanks for the feedback!
Enter two whole numbers and this calculator returns their HCF (highest common factor, also called the GCD or greatest common divisor) and their LCM (lowest common multiple). It is useful for checking maths homework, adding fractions with different denominators, and solving the "when will they meet again" type of word problem.
How the answer is calculated
The HCF comes from Euclid's algorithm: divide the larger number by the smaller, replace the larger with the remainder, and repeat until the remainder is zero. The last non-zero divisor is the HCF. For 84 and 120:
120 mod 84 = 36 84 mod 36 = 12 36 mod 12 = 0 → HCF = 12
The LCM then follows from the identity HCF × LCM = a × b, so LCM = 84 × 120 ÷ 12 = 840. That shortcut is why the calculator is instant even for large numbers.
Checking it with prime factorisation
School textbooks usually teach the prime factor method, and it is a good way to verify the result by hand:
- 84 = 2² × 3 × 7
- 120 = 2³ × 3 × 5
- HCF: take only the primes both numbers share, at their lowest power: 2² × 3 = 12.
- LCM: take every prime that appears, at its highest power: 2³ × 3 × 5 × 7 = 840.
Multiply the two results as a final check: 12 × 840 = 10,080, and so is 84 × 120. This product rule holds for any pair of numbers but not for three or more.
HCF or LCM? Reading word problems
| Question asks for | Use | Example |
|---|---|---|
| Largest equal piece, group or row | HCF | 84 cm and 120 cm ribbons cut into the longest equal pieces: 12 cm |
| First time events coincide | LCM | Bells ringing every 12 and 18 minutes ring together after 36 minutes |
| Common denominator | LCM | 1/12 + 1/18 = 3/36 + 2/36 = 5/36 |
A useful clue: if the answer must be smaller than or equal to the given numbers, you want the HCF; if it must be bigger, you want the LCM.
Inputs and special cases
- Two numbers only. For three, chain the calculation: find the LCM of the first two, then run it again with that result and the third number. The same works for the HCF.
- Co-prime numbers such as 17 and 5 have an HCF of 1, so their LCM is simply their product, 85.
- Decimals and negatives: decimals are rounded down to whole numbers and minus signs are ignored, since factors and multiples are defined for positive integers.
- Zero is rejected, because every number divides zero and it has no meaningful LCM.
To see whether a number has any factors at all besides 1 and itself, try the prime number checker. Once you have a common denominator, the fraction to decimal calculator converts and simplifies the result.