GCD & LCM Calculator
How do I find GCD and LCM?
Result
How it is calculated
The greatest common divisor (GCD) is the largest whole number dividing both inputs; the least common multiple (LCM) is the smallest positive number that both divide. The tool finds the GCD with Euclid's algorithm: replace the pair (a, b) with (b, a mod b) until the remainder is zero, and the last non-zero value is the GCD. The LCM then follows from LCM = a ÷ GCD × b, which avoids overflow. Both inputs must be positive whole numbers; decimals are truncated to integers and zero or negatives give no result. The GCD is used to simplify fractions, while the LCM gives a common denominator.
Worked example
Take 12 and 18. Euclid: 18 mod 12 = 6, so (12, 18) → (18, 12) → (12, 6); then 12 mod 6 = 0, so the GCD is 6. LCM = 12 / 6 × 18 = 2 × 18 = 36. So GCD = 6 and LCM = 36. Check: 6 × 36 = 216 = 12 × 18, because for any two numbers GCD × LCM equals their product.
Common mistakes
- Mixing up the two: the GCD is never larger than the smaller number, the LCM never smaller than the larger one.
- Entering decimals such as 12.9, which are cut to 12.
- Multiplying the numbers (12 × 18 = 216) and calling it the LCM, which only holds when they share no common factor.
- Using zero or negative numbers, which the tool does not accept.
About this calculator
This calculator finds the greatest common divisor (GCD) — the largest number that divides both inputs evenly — and the least common multiple (LCM) — the smallest number that both inputs divide into evenly — for two integers, using the Euclidean algorithm under the hood.
GCD is used to reduce a fraction to its simplest form (dividing numerator and denominator by their GCD) and comes up in scheduling problems, like finding the largest even group size two teams can both be split into. LCM is used to find a common denominator when adding or subtracting fractions, and to solve 'when do these two repeating events line up again' problems, like two buses that pass a stop every 12 and 18 minutes. Students working through math homework and anyone solving a scheduling or fraction problem by hand use this to check their work quickly.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
Two numbers at a time is the limit here, but you can chain the results: the GCD of three numbers is the GCD of the first pair's GCD and the third number, and the LCM works the same way. The LCM is handy for timing. Two buses leaving every 12 and 18 minutes are together again after 36 minutes. To simplify a fraction like 18/12, divide both parts by the GCD, 6, to get 3/2. What are you using it for?