Categories
GCD / LCM Calculator
Calculate the greatest common divisor (GCD) and least common multiple (LCM) of two or more integers.
Overview
Calculates the greatest common divisor (GCD) and least common multiple (LCM) from two or more positive integers.
Enter numbers separated by commas or newlines. You can also calculate three or more numbers together.
Usage
- 1
Enter the integers you want to calculate into "Numbers (two or more)", separated by commas or newlines.
- 2
Click "Calculate" to see the GCD and LCM.
Example
Input
12, 18
Output
GCD: 6, LCM: 36
Use Cases
Finding the GCD/LCM needed to reduce or find a common denominator for fractions
Finding when events with different periods (batch jobs, blink intervals, etc.) coincide, using the LCM
Checking the result of the Euclidean algorithm while learning algorithms
FAQ
Can I enter 0, negative numbers, or decimals?
No. Only integers of 1 or greater are supported. An error occurs if 0, a negative number, or a decimal is included.
How is the GCD/LCM of three or more numbers calculated?
By repeatedly combining two values at a time from the start (e.g., GCD(a,b,c) = GCD(GCD(a,b),c)), finding the GCD/LCM common to all the numbers.
What happens if I enter very large numbers?
If the LCM exceeds the range JavaScript can represent exactly as an integer (2^53-1), you will see the error "The least common multiple is too large to calculate accurately."
Notes
Only integers of 1 or greater are accepted. Input containing 0, negative numbers, or decimals produces an error.
Enter two or more numbers separated by commas, spaces, or line breaks.
If the least common multiple exceeds the range JavaScript can represent exactly as an integer (2^53 - 1), an error is shown instead of an incorrect value.
Related Tools
Convert numbers between binary, octal, decimal, and hexadecimal.
Calculate the result of bitwise operations such as AND, OR, XOR, NOT, and shifts, shown in decimal, binary, and hexadecimal.
Convert between units of length, weight, and temperature.
Calculate a new width or height while keeping the original aspect ratio.