GCD & LCM Calculator
Solve Greatest Common Divisor and Least Common Multiple for integers or fractions, with step-by-step arithmetic.
Number Type
Number Grid
Prime Factorization Breakdown
Number: 122² × 3
Number: 182 × 3²
Number: 242³ × 3
Step-by-Step Euclidean Algorithm (GCD of first two numbers)
18 = 12 × 1 + 6
12 = 6 × 2 + 0
The last non-zero remainder is 6. So, GCD = 6.
Greatest Common Divisor (GCD)
6
Least Common Multiple (LCM)
72
Fraction Rules: GCD of fractions equals GCD of numerators divided by LCM of denominators. LCM of fractions equals LCM of numerators divided by GCD of denominators.
GCD and LCM, explained with fractional methods
The greatest common divisor (GCD/HCF) identifies the largest positive integer dividing a set of values with zero remainders. The least common multiple (LCM) finds the smallest multiple shared by all values in a set.
Decimals and fractions can be solved by multiplying values to find base common factors, then scaling back the output divisors and multiples.
Built and maintained by Meet Shah · Last updated
What this tool is used for
- Reducing a fraction by finding the greatest common divisor.
- Finding a common denominator for adding fractions.
- Working out when two repeating cycles coincide.
- Simplifying a ratio to its smallest whole numbers.
- Solving a number theory exercise with the factors visible.
Frequently Asked Questions
- How does the Euclidean algorithm find the GCD?
- By replacing the larger number with its remainder against the smaller, repeatedly, until the remainder hits zero — the last non-zero remainder is the GCD. For 48 and 18: 48 = 18×2 + 12, 18 = 12×1 + 6, 12 = 6×2 + 0, so the GCD is 6. The tool prints every line of that trace.
- Why not just factorise both numbers?
- Because factorisation gets expensive fast and Euclid's method does not. The algorithm is roughly 2,300 years old and still standard, needing steps proportional to the DIGIT count rather than the value — it handles numbers far too large to factorise, which is why RSA key generation relies on it.
- How is the LCM derived from the GCD?
- LCM(a,b) = |a × b| ÷ GCD(a,b). The product counts every shared prime factor twice, so dividing by the GCD removes one copy of each. For 48 and 18 that is 864 ÷ 6 = 144. Dividing before multiplying also avoids overflow on large inputs.
- What is the GCD of a number and zero?
- The number itself, since every integer divides zero exactly. GCD(7, 0) = 7, and the algorithm handles it naturally — the loop simply never runs. GCD(0, 0) is the one undefined case, because every integer is a common divisor and there is no greatest one.
- What does it mean for two numbers to be coprime?
- That their GCD is 1 — they share no prime factor. 8 and 15 are coprime despite neither being prime. It is the condition for a fraction being fully reduced, for a modular inverse to exist, and for the Chinese Remainder Theorem to apply, which is why it shows up far beyond arithmetic homework.
Common errors and gotchas
- Confusing GCD with LCM, which move in opposite directions as numbers grow.
- Assuming GCD is 1 means the numbers share nothing, when it means exactly that they are coprime.
- Computing GCD with zero, where the convention is the other number rather than an error.
- Overflowing an LCM of several large numbers, which grows very quickly.
- Using GCD on non-integers, where the concept does not apply.
Related Calculators tools
Percentage Calculator
Solve percentage, increase, and change calculations.
Age Calculator
Calculate exact age in years, months, and days.
Unix Timestamp Converter
Convert Unix epoch timestamps to and from human dates.
Tip Calculator
Calculate tip and split the bill between people.
Aspect Ratio Calculator
Solve width or height for a target aspect ratio.
Temperature Converter
Convert between Celsius, Fahrenheit, and Kelvin.
Data Storage Converter
Convert between bytes, KB, MB, GB, TB, and more.
Discount Calculator
Calculate sale price and savings from a discount.