Skip to content

GCD/LCM Calculator

Calculate the greatest common divisor and least common multiple online. Free GCD/LCM calculator with step-by-step solutions shown.

Calculators
Instant results
GCD
12
Greatest Common Divisor
LCM
72
Least Common Multiple

How to Use GCD/LCM Calculator

1

Enter numbers

Type two or more positive integers separated by commas into the input.

2

Calculate

The calculator returns both the greatest common divisor and the least common multiple in a single pass.

3

View steps (optional)

Some calculators expand the Euclidean algorithm step by step, which is genuinely useful when you are trying to understand why the answer is what it is rather than just see it.

4

Use in your work

Apply the result wherever you need it — fraction simplification, common denominator math, scheduling problems, or verifying a custom GCD implementation.

When to Use GCD/LCM Calculator

Math homework and classroom support

Greatest common divisor and least common multiple show up across middle school and high school number theory units. The calculator returns answers immediately and can show the Euclidean algorithm step by step, which makes it useful both for students learning the concept and for teachers checking dozens of problem sets without doing every calculation by hand.

Fraction simplification and arithmetic

Reducing 12/16 to 3/4 means dividing top and bottom by their GCD, which is 4. Adding fractions like 1/4 plus 1/6 means finding the LCM of the denominators, which is 12, and rewriting both fractions over that common denominator. The calculator hands you both numbers in one pass, which speeds up any work that involves fractions in classroom problems or real recipes and measurements.

Programming and algorithm checks

GCD and LCM problems appear constantly in coding interviews, algorithm exercises, and competitive programming. Running your custom implementation against the calculator on a few representative inputs catches edge cases you might have missed, especially around zero, negative numbers, and very large values where the Euclidean algorithm has interesting behavior.

Number theory exploration

The identity GCD(a,b) times LCM(a,b) equals a times b connects these two operations elegantly, and coprime pairs — those with GCD equal to 1 — sit at the heart of RSA and other cryptographic schemes. The calculator gives you a quick way to play with these relationships and build intuition before diving into the heavier theory.

GCD/LCM Calculator Examples

Simple GCD

Input
GCD(12, 18)
Output
6

Both 12 and 18 are divisible by 1, 2, 3, and 6. The greatest of those shared divisors is 6, which is exactly what the Euclidean algorithm produces in two steps.

Simple LCM

Input
LCM(4, 6)
Output
12

The least common multiple of 4 and 6 is the smallest number both divide cleanly. Using the formula LCM = a times b divided by GCD, you get 24 divided by 2, which lands on 12.

Multiple numbers

Input
GCD(12, 18, 24)
Output
6

Multi-number GCD reduces to pairwise application. Take GCD of 12 and 18 to get 6, then take GCD of that result with 24, which is also 6. The same approach extends to any quantity of inputs.

Tips & Best Practices for GCD/LCM Calculator

  • 1.The Euclidean algorithm — GCD(a,b) equals GCD(b, a mod b) — is the standard implementation and runs in logarithmic time, which means it stays fast even on numbers with hundreds of digits.
  • 2.For any pair of numbers, GCD times LCM equals the product. That identity sometimes lets you compute one quantity from the other rather than running both algorithms separately.
  • 3.A GCD of 1 means the two numbers are coprime, sharing no common factor larger than 1. This property is what makes RSA encryption work and shows up throughout number theory.
  • 4.When two numbers are coprime, their LCM is just their product, no division required. That makes the math much faster when you can spot the relationship in advance.
  • 5.For three or more numbers, both GCD and LCM reduce pairwise. Compute the result for the first two, then combine with the third, and so on through the list.
  • 6.LCM has a real-world meaning in scheduling. Two events that recur every 12 and 18 days will coincide every 36 days, which is the LCM of the two periods.

Frequently Asked Questions

The greatest common divisor of two or more numbers is the largest number that divides all of them with no remainder. GCD of 12 and 18 is 6 because both numbers are divisible by 1, 2, 3, and 6, and 6 is the largest of those shared divisors. The concept underpins fraction simplification and shows up throughout number theory.