Free LCM & GCD Calculator
Find the greatest common divisor (GCD) and least common multiple (LCM) of any list of whole numbers in one click, using Euclid's algorithm with the steps shown.
Enter positive whole numbers separated by commas, spaces, or new lines.
Check: LCM = (12 Γ 18) Γ· 6 = 36.
Quick answer
The GCD (greatest common divisor) is the largest integer that divides every number with no remainder, and the LCM (least common multiple) is the smallest positive integer that every number divides into evenly. For two numbers a and b the key identity is LCM(a, b) = (a Γ b) / GCD(a, b); for example GCD(12, 18) = 6, so LCM(12, 18) = (12 Γ 18) / 6 = 216 / 6 = 36. For longer lists both values are folded pairwise: GCD(a, b, c) = GCD(GCD(a, b), c) and the same nesting applies to the LCM.
Formula & method
LCM(a, b) = (a Β· b) / GCD(a, b)
- a, b β the two positive integers being compared
- GCD(a, b) β greatest common divisor (largest number dividing both)
- LCM(a, b) β least common multiple (smallest number both divide into)
The fundamental link between LCM and GCD for two integers. Compute the GCD first, then divide the product by it. This avoids overflow far better than multiplying everything up front.
GCD(a, b) = GCD(b, a mod b), GCD(a, 0) = a
Euclid's algorithm: repeatedly replace the larger number by the remainder of dividing the two until one becomes zero. The non-zero survivor is the GCD.
GCD(a, b, c, β¦) = GCD(GCD(a, b), c, β¦); LCM(a, b, c, β¦) = LCM(LCM(a, b), c, β¦)
For three or more numbers, fold the operation pairwise from left to right. The result is independent of the order you process the values.
Examples
- Input
- 12, 18
- Result
- GCD = 6, LCM = 36
- Why
- Euclid: GCD(12, 18) β GCD(18, 12) β GCD(12, 6) β GCD(6, 0) = 6. Then LCM = (12 Γ 18) / 6 = 216 / 6 = 36. So 36 is the smallest number that both 12 and 18 divide into evenly (36 Γ· 12 = 3, 36 Γ· 18 = 2).
- Input
- 8, 12, 20
- Result
- GCD = 4, LCM = 120
- Why
- GCD: GCD(8, 12) = 4, then GCD(4, 20) = 4. LCM: LCM(8, 12) = (8 Γ 12) / 4 = 24, then LCM(24, 20) = (24 Γ 20) / GCD(24, 20) = 480 / 4 = 120. Check: 120 Γ· 8 = 15, 120 Γ· 12 = 10, 120 Γ· 20 = 6.
- Input
- 15, 25
- Result
- GCD = 5, LCM = 75
- Why
- 15 = 3 Γ 5 and 25 = 5 Γ 5 share only the factor 5, so GCD = 5. LCM = (15 Γ 25) / 5 = 375 / 5 = 75. (If the numbers had no common factor at all, the GCD would be 1 and the LCM would simply be their product.)
- Input
- 4, 6, 8, 12
- Result
- GCD = 2, LCM = 24
- Why
- GCD folds to 2: GCD(4, 6) = 2, GCD(2, 8) = 2, GCD(2, 12) = 2. LCM folds to 24: LCM(4, 6) = 12, LCM(12, 8) = (12 Γ 8) / 4 = 24, LCM(24, 12) = 24. So 24 is the smallest common multiple of all four values.
When to use this tool
- Adding or subtracting fractions: the LCM of the denominators gives the least common denominator, the smallest denominator you can convert every fraction to.
- Simplifying a fraction or ratio to lowest terms by dividing the numerator and denominator by their GCD.
- Solving scheduling and cycle problems β e.g. two events that repeat every 8 and 12 days next coincide after LCM(8, 12) = 24 days.
- Splitting quantities into the largest equal groups (GCD) or finding gear, packaging, or tiling sizes that line up evenly.
Common mistakes
- Multiplying all the numbers to get the LCM. The product is always *a* common multiple but rarely the *least* one β 12 Γ 18 = 216 is a common multiple, but the LCM is only 36. Always divide by the GCD.
- Confusing GCD with LCM. The GCD is never larger than the smallest input, while the LCM is never smaller than the largest input. If your 'GCD' exceeds an input, you computed the wrong one.
- Entering decimals or fractions. GCD and LCM are defined for whole numbers (integers) only. Values like 2.5 or 3/4 are rejected β scale them to integers first if needed.
- Including zero in the list. LCM is undefined when any value is 0 (zero has no positive multiples in common), so this tool requires positive integers and ignores blanks.
Frequently asked questions
What is the difference between GCD and LCM?
The GCD (greatest common divisor, also called GCF or HCF) is the largest number that divides all of your inputs without a remainder, so it is always β€ the smallest input. The LCM (least common multiple) is the smallest positive number that all of your inputs divide into evenly, so it is always β₯ the largest input. For 12 and 18 the GCD is 6 and the LCM is 36.
Is GCD the same as GCF or HCF?
Yes. GCD (greatest common divisor), GCF (greatest common factor), and HCF (highest common factor) are three names for the exact same quantity. Different textbooks and countries prefer different abbreviations, but they all mean the largest integer that divides every number in the set.
How does the calculator find the GCD so fast?
It uses Euclid's algorithm, which repeatedly replaces the larger number with the remainder of dividing the pair until one of them is zero β the other value is then the GCD. It is dramatically faster than listing factors and works in just a handful of steps even for very large numbers.
Why isn't the LCM just all the numbers multiplied together?
Because the product double-counts any shared factors. For 12 and 18 the product is 216, but both share a factor of 6, so the true LCM is 216 Γ· 6 = 36. The correct formula is LCM(a, b) = (a Γ b) / GCD(a, b), which removes the overlap.
Can I find the LCM or GCD of more than two numbers?
Yes. Enter as many positive integers as you like, separated by commas or spaces. The tool folds the operation pairwise β GCD(a, b, c) = GCD(GCD(a, b), c) and likewise for the LCM β so the result is correct for any length of list and does not depend on the order.
What happens if I enter a decimal, a fraction, or zero?
GCD and LCM are only defined for positive whole numbers, so the calculator ignores blanks and rejects non-integer or non-positive entries. If you need the GCD of fractions, first scale each one to an equivalent integer (for example multiply 0.5 and 0.75 by 4 to get 2 and 3).
Sources & references
- Wikipedia β Least common multiple
- Wikipedia β Greatest common divisor
- Wikipedia β Euclidean algorithm
External references open in a new tab. We are independent and not affiliated with these organizations.
- β Free to use
- β No sign-up required
- β Runs entirely in your browser β nothing is uploaded.
- β Formula and method shown above
Provided βas isβ for general information only β results may be inaccurate, so verify before you rely on them. No warranty; use at your own risk.
Built and reviewed by HIFreeTools against the formula shown above and any authoritative references cited on this page. See our methodology and editorial standards.
Related tools
- Factorial CalculatorCalculators
- Prime Number CheckerCalculators
- Fraction CalculatorCalculators
- Percentage CalculatorCalculators
- Permutation and Combination CalculatorCalculators
Embed this tool on your site
Free to embed, no sign-up. Paste this code where you want the lcm & gcd calculator to appear: