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
- Enter the integers you want to calculate into "Numbers (two or more)", separated by commas or newlines.
- 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."
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.