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.
Everyday tool
Enter whole numbers separated by commas or spaces to calculate their GCD and LCM.
Works in your browser. Your files stay on your device.
Greatest common divisor (GCD):
Least common multiple (LCM):
About this tool
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
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.
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.
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.
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.
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.
Common questions
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.
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.
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.
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.
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.
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.
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.
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.
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.
Enter whole numbers separated by commas or spaces. The calculator finds the greatest common divisor and least common multiple of the set.