Skip to content
1001 Tools
sr
Math & education

GCD and LCM Calculator

Enter two or more whole numbers to get both their greatest common divisor and least common multiple. Handy for simplifying fractions, finding common denominators, and scheduling problems where cycles line up. It computes exactly and runs on your device.

Enter two or more whole numbers, separated by spaces, commas or new lines.

Enter at least two numbers.

How it works

The GCD (also called highest common factor) is the largest number that divides all your inputs evenly; the LCM is the smallest number they all divide into. The tool finds the GCD with the Euclidean algorithm — repeatedly replacing the larger number with the remainder — then derives the LCM from the identity a×b = GCD×LCM.

For more than two numbers it folds the operation across the list: gcd(a, b, c) = gcd(gcd(a, b), c), and the same for LCM. Separate values with spaces, commas, semicolons or new lines. If any value is 0, the LCM is reported as 0, since zero has no positive multiple in common.

Practical examples

Simplifying a fraction

To reduce 18/24, take the GCD of 18 and 24 — which is 6 — and divide both by it to get 3/4. The tool gives that GCD instantly.

Common denominator

Adding 1/4 and 1/6 needs a common denominator: the LCM of 4 and 6 is 12, so you rewrite them as 3/12 and 2/12.

Three numbers at once

For 12, 18 and 24 the GCD is 6 and the LCM is 72 — useful when several repeating cycles must all align.

Frequently asked questions

What is the difference between GCD and LCM?

The greatest common divisor is the biggest number that divides all your inputs; the least common multiple is the smallest number all your inputs divide into. GCD is always ≤ the smallest input; LCM is always ≥ the largest.

Is GCD the same as HCF?

Yes. “Highest common factor” (HCF) is the term used in many school curricula, including in the region; “greatest common divisor” (GCD) is the same thing under a different name.

Can I enter more than two numbers?

Yes. Enter as many whole numbers as you like, separated by spaces, commas, semicolons or new lines. The GCD and LCM are computed across the entire list at once.

What happens if I include 0?

The GCD of a number and 0 is that number (0 is divisible by everything), so 0 doesn’t change the GCD. The LCM becomes 0, because there’s no positive number that 0 divides into — a convention the tool follows.

How do you compute the LCM?

Via the GCD: for two numbers, LCM = a × b ÷ GCD. Dividing by the GCD before multiplying keeps the intermediate value small, avoiding overflow for large inputs. For lists, it’s applied pairwise across all numbers.

What is the Euclidean algorithm?

An ancient, very fast method for the GCD: divide the larger by the smaller, keep the remainder, and repeat until the remainder is zero. The last non-zero remainder is the GCD. It’s far quicker than listing factors.

Does it accept decimals or negatives?

It works with non-negative whole numbers, which is where GCD and LCM are defined. Decimals aren’t accepted; for negatives, the magnitude gives the same GCD and LCM, so enter the positive values.

Are my numbers kept private?

Yes. The calculation runs entirely in your browser; nothing is uploaded and analytics never receives your numbers.

Related tools