How to find the GCD and LCM
- 1.
Enter numbers
Type at least two integers separated by spaces, commas or semicolons, e.g. 48 180 or 24, 36, 60.
- 2.
Read the GCD and LCM
Results appear instantly, with a note whether the numbers are coprime (GCD = 1).
- 3.
Check the factorisation
See each number written as a product of prime powers, e.g. 180 = 2² · 3² · 5.
- 4.
Follow the algorithm
The Euclidean algorithm lists each division with remainder for every pair of numbers.
The Euclidean algorithm
Divide the larger number by the smaller one with remainder, then divide the previous divisor by the remainder, and repeat until the remainder is 0. The last non-zero remainder is the GCD. For 48 and 180:
- 180 = 3 · 48 + 36
- 48 = 1 · 36 + 12
- 36 = 3 · 12 + 0 → GCD = 12
The method needs only a handful of steps even for numbers with dozens of digits, which is why the calculator can handle integers up to 200 digits exactly. With three or more numbers it works pairwise: GCD(24, 36, 60) = GCD(GCD(24, 36), 60) = GCD(12, 60) = 12, and each pair gets its own step-by-step table (the first 40 steps are shown).
GCD and LCM from prime factors
Write each number as a product of primes: 48 = 2⁴ · 3 and 180 = 2² · 3² · 5.
- GCD - take the primes common to all numbers with the lowest power: 2² · 3 = 12.
- LCM - take every prime that appears with the highest power: 2⁴ · 3² · 5 = 720.
For exactly two numbers there is a shortcut: GCD · LCM = a · b, so LCM = 48 · 180 / 12 = 720. This identity does not hold for three or more numbers - use the factor method or compute pairwise. Numbers up to 30 digits are factorised (trial division plus Pollard’s rho); for longer numbers the factorisation is skipped, but GCD and LCM are still exact.
GCD vs LCM: which one do I need?
| Problem | Use | Example |
|---|---|---|
| Simplify a fraction | GCD | 48/180 ÷ 12 = 4/15 |
| Add fractions with different denominators | LCM | 1/4 + 1/6 → denominator 12 |
| Cut materials into equal pieces with no waste | GCD | boards of 120 cm and 84 cm → pieces of 12 cm |
| When do repeating events coincide? | LCM | buses every 12 and 18 min meet every 36 min |
| Gear teeth, tiling, scheduling | LCM | gears with 20 and 30 teeth realign after 60 teeth |
For full fraction arithmetic use the fraction calculator.
Common mistakes
- Mixing up the powers - GCD uses the lowest exponent, LCM the highest. Swapping them is the most frequent error.
- Forgetting primes that appear only once - the 5 in 180 belongs to the LCM even though 48 has no factor 5.
- Using a · b / GCD for three numbers - it only works for pairs.
- Zero and negatives - GCD(a, 0) = |a|, LCM with a zero is 0, and negative inputs are treated as their absolute values.
Frequently asked questions
How do I find the GCD of two numbers?
+
How do I find the LCM?
+
What is the GCD of three numbers?
+
Is GCD the same as HCF or GCF?
+
What does coprime mean?
+
What is the GCD with zero?
+
Does it work with large numbers?
+
Updated: