Everyday tool

GCD and LCM Calculator

Enter whole numbers separated by commas or spaces to calculate their GCD and LCM.

Runs in your browser. No upload.

Works in your browser. Your files stay on your device.

Greatest common divisor (GCD): —

Least common multiple (LCM): —

About this tool

GCD and LCM Calculator made simple.

The greatest common divisor is the largest integer that divides every input. The least common multiple is the smallest positive integer shared by all inputs. Zero and negative integers are supported; the LCM is undefined when every input is zero.

Guide

Using GCD and LCM Calculator

The GCD and LCM Calculator takes a list of whole numbers and gives two results. The greatest common divisor is the biggest whole number that divides every number in the list. The least common multiple is the smallest positive number that every one of them divides into. You can enter from 2 to 100 numbers, separated by commas or spaces. Negative numbers and zero are accepted. The numbers must be whole, with no decimals or fractions.

How to use it

  1. Type at least two whole numbers in the box, separated by commas, spaces or semicolons. You can enter up to 100.
  2. Press Calculate GCD and LCM.
  3. Read the two results under the button: the greatest common divisor and the least common multiple.
  4. Press Clear to empty the box and the results before you start a new set.

Worked examples

Two numbers

You enter
Numbers
12, 18
You get
Gcd
6
Lcm
36

The biggest number that divides both 12 and 18 is 6. The smallest number both divide into is 36. Also, 6 times 36 equals 12 times 18.

Run through the tool’s own code.

Three numbers

You enter
Numbers
48, 180, 300
You get
Gcd
12
Lcm
3600

In prime factors, 48 is 2^4 x 3, 180 is 2^2 x 3^2 x 5 and 300 is 2^2 x 3 x 5^2. Take the smallest powers for the GCD (12) and the biggest for the LCM (3600).

Run through the tool’s own code.

A zero in the list

You enter
Numbers
0, 5
You get
Gcd
5
Lcm
0

Every number divides zero, so the GCD is the other number. The tool follows the rule that the LCM is zero when any input is zero. If every input is zero, the LCM shows as undefined.

Run through the tool’s own code.

Negative input and very large numbers

You enter
Numbers
-12, 18
You get
Gcd
6
Lcm
36

The signs are ignored, so -12 is treated as 12. The tool uses big-integer math, so two large primes such as 1000000007 and 998244353 give a GCD of 1 and an exact LCM of 998244359987710471.

Run through the tool’s own code.

When it helps

  • Simplify a fraction by dividing the top and bottom by their GCD.
  • Find a common denominator for adding fractions by taking the LCM of the denominators.
  • Work out when two or more repeating events line up again, such as buses that run every 12 and 18 minutes.
  • Check homework answers on factors and multiples.
  • Split items into equal groups with no leftovers by using the GCD of the counts.

Limits to keep in mind

  • You need between 2 and 100 numbers. A single number shows an error.
  • Only whole numbers work. Decimals, fractions and letters give a 'Use whole numbers only' message.
  • Each number can have up to 1000 digits, and an LCM longer than 1000 digits is refused as too large to display.
  • Negative numbers are treated by their absolute value, so the results are never negative.
  • The tool gives answers only. It does not show the steps or the prime factors.

Tips

  • To simplify a fraction, enter the top and bottom numbers and divide both by the GCD you see.
  • For two numbers, check your answer with the rule GCD times LCM equals the product of the two numbers.
  • If the GCD comes out as 1, the numbers share no factor other than 1, and the LCM is their product.
  • Paste numbers from a list or sheet, because spaces, commas, semicolons and line breaks all work as separators.

Common questions

About GCD and LCM Calculator.

What is the difference between GCD and LCM?

The GCD is the largest number that divides all your numbers evenly, so it is never larger than the smallest of them. The LCM is the smallest positive number that all of them divide into evenly, so it is never smaller than the largest of them.

How do I find the GCD and LCM of more than two numbers?

Enter them all in the box, up to 100, and press the button. The tool combines them one after another, which gives the same result as working with the whole set. You do not need to do it two at a time by hand.

Can I use negative numbers or zero?

Yes. A negative number is treated as its positive twin. Zero is accepted too. If any input is zero, the LCM is zero. If every input is zero, the GCD is 0 and the LCM is shown as undefined, because no positive common multiple exists.

Why does a single number give an error?

The tool is built for sets of at least two numbers, so one number gives the message 'Enter 2 to 100 whole numbers'. The GCD of one number would just be that number, so you can read it off without a calculator.

Can I enter decimals such as 2.5 and 7.5?

No. Only whole numbers are allowed, and a decimal point gives an error. If your numbers are decimals, multiply them all by the same power of 10 until they are whole, run the tool, then think about how the scaling changes the answer.

Is there a rule linking the GCD and the LCM?

For two numbers, the GCD times the LCM equals the product of the two numbers. For 12 and 18 that is 6 times 36, which is 216, the same as 12 times 18. The rule does not hold the same way for three or more numbers.

How big can the numbers be?

Each number can have up to 1000 digits, because the tool uses big integers rather than ordinary floating-point numbers. The LCM can grow much larger than the inputs, so if it would pass 1000 digits the tool says it is too large to display.

Does the tool show the working steps?

No. It shows only the two final values. If you want the steps, break each number into prime factors by hand, or use the Euclidean method of repeated division with remainders, and compare your result with this tool.

Are my numbers sent anywhere?

The page says the calculation works in your browser and your input stays on your device. The numbers are not uploaded. The result is gone when you close the tab, so write down anything you want to keep.

How do I find the GCD and LCM?

Enter whole numbers separated by commas or spaces. The calculator finds the greatest common divisor and least common multiple of the set.