GCD & LCM Calculator
Enter two or three whole numbers to get their greatest common divisor and least common multiple, with the working shown.
GCD by Euclid's algorithm: GCD(a, b) = GCD(b, a mod b). LCM(a, b) = a × b ÷ GCD(a, b).
How to use the GCD & LCM calculator
- Enter the first and second whole numbers.
- Add a third number if you need it, or leave it blank.
- Press “Calculate GCD & LCM” to see both answers and the Euclid steps.
GCD & LCM calculation example
For 84 and 126: 84 = 2² × 3 × 7 and 126 = 2 × 3² × 7. GCD = 2 × 3 × 7 = 42. LCM = 84 × 126 ÷ 42 = 252.
Everyday uses
- GCD: cut two lengths of cloth (84 cm and 126 cm) into the largest equal pieces with no waste — 42 cm.
- LCM: two buses every 12 and 18 minutes leave together again after 36 minutes.
- Simplifying fractions: divide by the GCD.
GCD & LCM calculator: common questions
- How is the GCD worked out?
- By Euclid's algorithm: repeatedly replace the pair (a, b) with (b, a mod b) until the remainder is 0. The last non-zero remainder is the GCD.
- How is the LCM worked out?
- LCM(a, b) = a × b ÷ GCD(a, b). For example, LCM(48, 180) = 48 × 180 ÷ 12 = 720.
- What about three numbers?
- The GCD and LCM are found for the first two numbers, then combined with the third: GCD(a, b, c) = GCD(GCD(a, b), c), and the same for the LCM.
- Is my data stored?
- No. The calculation runs in your browser.
- What is the quickest way to find a GCD by hand?
- Euclid's method: replace the larger number by the remainder of dividing it by the smaller. 126 mod 84 = 42, 84 mod 42 = 0, so the GCD is 42.