GCD and LCM Calculator
Enter two or more whole numbers and get their greatest common divisor (GCD) and least common multiple (LCM) at once. For two numbers the tool shows every step of the Euclidean algorithm, and for up to ten numbers it shows each prime factorization, so you can see why the answer is what it is. Numbers can have up to 18 digits, and results are exact. Everything runs in your browser.
Prime factorizations
- 48 = 2^4 x 3
- 18 = 2 x 3^2
The GCD takes each prime to its lowest power, and the LCM takes each prime to its highest power.
Euclidean algorithm
- 48 = 18 x 2 + 12
- 18 = 12 x 1 + 6
- 12 = 6 x 2 + 0
Each line divides the larger number by the smaller one. The divisor of the last line, the one that leaves a remainder of 0, is the GCD: 6.
Related Tools
[4 suggestions]Prime Factorization Calculator
Break any whole number up to 18 digits into its prime factors, with division steps, all divisors and a prime check.
Math & MoneyFraction Calculator
Add, subtract, multiply and divide fractions, mixed numbers and decimals, simplify to lowest terms and see the steps.
Math & MoneyMean, Median and Mode Calculator
Find the mean, median, mode, range, quartiles, variance and standard deviation of a list of numbers, with exact decimal arithmetic.
Math & MoneyPercentage Calculator
Find a percentage of a number, what percent one number is of another, a percentage increase or decrease, or a number raised or lowered by a percentage.
Math & MoneyAbout the GCD and LCM Calculator
The GCD and LCM calculator uses the Euclidean algorithm, which repeatedly replaces the larger number by its remainder after dividing by the smaller one until the remainder is 0. The last divisor is the GCD. The LCM of two numbers is their product divided by their GCD, and for a longer list the tool combines the numbers one at a time, so the order does not change the result. It calculates with exact BigInt arithmetic, so a result such as the LCM of two 18-digit numbers is not rounded, even when it has 36 digits. A GCD of 1 means the numbers are coprime. The prime factorizations make the rule visible: the GCD takes every prime to its lowest power and the LCM takes every prime to its highest power. Input is read strictly: whole numbers of 1 or more, separated by spaces, commas or semicolons, and a decimal, a negative number or a stray letter is reported by name instead of guessed. The results were compared with the gcd and lcm functions of Python on 3,000 random lists, with no differences. Everything runs in your browser and nothing is uploaded.
What is the greatest common divisor?▾
It is the largest whole number that divides every number in the list without a remainder. The GCD of 48 and 18 is 6, because 6 divides both and nothing larger does.
What is the least common multiple?▾
It is the smallest positive number that every number in the list divides evenly. The LCM of 4 and 6 is 12. It is the common denominator you need to add fractions.
How are the GCD and the LCM related?▾
For two numbers, GCD times LCM equals the product of the numbers. So the LCM is the product divided by the GCD. For example, 48 x 18 = 864, and 864 / 6 = 144, the LCM of 48 and 18.
What does it mean when the GCD is 1?▾
The numbers are coprime: they share no prime factor. Their LCM is then simply their product, and a fraction made from them cannot be simplified.
Is my data uploaded?▾
No. The calculation runs in your browser, and what you type is not sent anywhere or stored.