LCM and GCD Calculator

This free lcm and gcd calculator finds the least common multiple (LCM) and greatest common divisor (GCD) of two or more integers — instantly, on any device. Enter your numbers and get both answers at once, plus a step-by-step showing of the Euclidean algorithm so you can see exactly how the GCD was found.

Enter your numbers

Your results

GCD
LCM

Results update instantly as you type. All calculations happen in your browser — your numbers are never sent anywhere.

How to use this calculator

Type or paste at least two integers into the box above. You can separate them with commas, spaces, semicolons or line breaks — whatever is easiest. The answers update automatically as you type, so there is nothing to submit.

The top panel shows the two headline answers: the GCD (greatest common divisor) and the LCM (least common multiple) of all your numbers. The table below lists the count, the numbers as used (absolute values), and a fully worked step-by-step of the Euclidean algorithm for the first pair.

Negative numbers are fine — they are converted to their absolute values first, since LCM and GCD only depend on the magnitude of each number. Zeros are allowed too: the GCD of n and 0 is n, and the LCM of anything with 0 is 0.

How it works

The Euclidean algorithm finds the GCD by repeated division with remainders. To find GCD(18, 12): divide 18 by 12 to get remainder 6, then divide 12 by 6 to get remainder 0 — so the last non-zero remainder, 6, is the GCD. When the remainder hits zero, you stop. It is fast even for very large numbers because each step at least halves the values.

The LCM formula is: LCM(a, b) = |a × b| ÷ GCD(a, b). Once the GCD is known, the LCM falls out immediately — for 12 and 18: 12 × 18 ÷ 6 = 216 ÷ 6 = 36. For three or more numbers, both operations are folded pairwise: LCM(a, b, c) = LCM(LCM(a, b), c), and likewise for GCD.

Why they matter: the GCD simplifies fractions (divide top and bottom by it), while the LCM is the tool for adding fractions with different denominators — you need the smallest common denominator. Scheduling uses the same idea: if one event repeats every 4 days and another every 6, they coincide every LCM(4, 6) = 12 days. These are exact integer results, not estimates.

Frequently asked questions

How do you find the LCM and GCD of two numbers?

For the GCD, repeatedly replace the larger number by the remainder of dividing it by the smaller one until the remainder is zero — the last non-zero remainder is the GCD (this is the Euclidean algorithm). For the LCM, use the formula LCM(a, b) = |a × b| ÷ GCD(a, b). For 12 and 18: the GCD is 6, so the LCM is 12 × 18 ÷ 6 = 36.

What is the difference between LCM and GCD?

The GCD (greatest common divisor) is the largest whole number that divides both numbers evenly, while the LCM (least common multiple) is the smallest whole number that both numbers divide into evenly. For 12 and 18, the GCD is 6 and the LCM is 36. The two are linked by the formula LCM(a, b) × GCD(a, b) = |a × b|.

Can you calculate the LCM or GCD of more than two numbers?

Yes. Both operations are associative, so you can fold them pairwise: the GCD of 4, 6 and 8 is GCD(GCD(4, 6), 8) = 2, and the LCM of 4, 6 and 8 is LCM(LCM(4, 6), 8) = 24. Enter any list of integers separated by commas, spaces or line breaks and this calculator does the folding for you.

What is the LCM or GCD when one of the numbers is zero?

The GCD of any number n and zero is |n|, because every number divides zero. The LCM of any number and zero is 0, since 0 is the only multiple they share. Negative numbers are handled by taking absolute values first, so signs never change the answer.

Related calculators