Interactive number theory

LCM-GCD Calculator

Find the greatest common divisor and least common multiple of two or more positive integers. See each Euclidean step, prime factors and common multiples.

Exact integer results · visual explanations · worked steps

Enter your numbers

Use 2 to 8 positive whole numbers. Each may contain up to 100 digits.

Exact results

GCD & LCM

Greatest common divisor (GCD)

6

The largest positive integer that divides every input without a remainder.

Least common multiple (LCM)

36

The smallest positive integer divisible by every input.

Euclidean algorithm, step by step

Divide, keep the remainder, then repeat. For several numbers, apply the result to the next input.

Prime factor comparison

The lowest exponent of each prime gives the GCD; the highest exponent gives the LCM.

Where multiples first meet

The highlighted number is the first positive multiple shared by both inputs.

Try an example

How GCD and LCM work together

The GCD helps simplify fractions or ratios. The LCM helps find a common denominator or the first time repeating schedules coincide.

GCD(a, b) × LCM(a, b) = a × b

Simplifying a fraction

For 12/18, divide numerator and denominator by GCD(12, 18) = 6 to get 2/3.

12/18 = 2/3

Repeating events

If one event repeats every 12 days and another every 18 days, both coincide again after LCM(12, 18) = 36 days.

Exact arithmetic, even for large integers

All calculations use integer arithmetic rather than floating-point approximations. The visual prime comparison is deliberately limited to values that can be factored quickly.

Frequently asked questions

What is the difference between GCD and LCM?

GCD is the greatest number that divides every input. LCM is the smallest positive number divisible by every input.

Are the results exact?

Yes. The calculator uses exact integer arithmetic, including for inputs larger than the usual browser number limit.

Can I use more than two numbers?

Yes. Add up to eight positive integers. The GCD and LCM are calculated across all of them.

Why are prime factors useful?

Take the lowest exponent of each prime for the GCD and the highest for the LCM.

What if the numbers are coprime?

Their GCD is 1. For two coprime numbers, their LCM equals their product.

Why is there no prime graphic for a very large number?

Finding the prime factors of a huge integer can be slow. The calculator still gives exact GCD and LCM results without factoring it.