GCD and LCM Calculator
GCD and LCM of two to six numbers. Euclidean algorithm steps, the prime factor method, the division ladder and the check GCD · LCM = a · b.
What are the GCD and the LCM?
The GCD (greatest common divisor) is the largest number that divides all the given numbers. The LCM (least common multiple) is the smallest positive number that all of them divide. You use the GCD to reduce fractions and the LCM to find a common denominator. This tool finds both for two to six numbers and shows three separate methods step by step.
The Euclidean algorithm
Divide the larger number by the smaller one and keep the remainder. Then divide the smaller number by that remainder. Repeat until the remainder is zero. The last divisor is the GCD. For 1071 and 462: 1071 = 462 · 2 + 147, 462 = 147 · 3 + 21, 147 = 21 · 7 + 0, so the GCD is 21. This method needs no factoring and stays fast for very large numbers.
The prime factor method
Each number is split into prime factors. The GCD takes the smallest exponent of every shared prime and the LCM takes the largest exponent of every prime. For 48 = 2⁴ · 3 and 18 = 2 · 3² that gives GCD = 2 · 3 = 6 and LCM = 2⁴ · 3² = 144.
The division ladder
This is the layout taught at school. Write the numbers side by side and divide by primes, smallest first. Mark a prime when it divides every number in the row. The product of the marked primes is the GCD and the product of all the primes is the LCM.
Check and limits
For two numbers GCD · LCM = a · b always holds: 6 · 144 = 864 = 48 · 18. For three or more numbers it usually does not. The tool works with non-zero whole numbers only. Decimals and fractions are not accepted and negative numbers are replaced by their absolute values.
Frequently asked questions
How do you calculate the GCD and LCM of two numbers?
In this example, for 24 and 36, the GCD is 12 and the LCM is 72, found using the Euclidean algorithm. Repeated division continues until the remainder is zero, and the last nonzero remainder gives the greatest common divisor. Dividing the product by the GCD gives the LCM for two numbers, but this shortcut does not generally apply to a longer list.
Related calculators
-
Mathematics
Prime Number and Prime Factorization Calculator
Is the number prime, its prime factors, its divisors, the previous and next prime. All primes in a range with the sieve of Eratosthenes. Exact up to 2⁶⁴, with steps. -
Mathematics
Combination, Permutation and Factorial Calculator
n!, P(n, r), C(n, r), permutations of repeated items, combinations with repetition and circular permutations. Exact to the last digit, with the expansion shown. -
Mathematics
Proportion Calculator: Direct, Inverse and Ratio Split
Find the missing value in direct or inverse proportion, or split a total in a ratio such as 1:2:3. See formulas and steps. Free, no account needed. -
Mathematics
Scientific Calculator
Type an expression and see the result at once: trigonometry, logarithms, powers, roots, factorials. Degree and radian modes, memory and history, all in your browser. -
Mathematics
Absolute Value and Piecewise Function Calculator
Solves absolute value equations and inequalities step by step, evaluates expressions, writes them piecewise and evaluates piecewise functions. -
Mathematics
Algebraic Expression Simplifier
Simplifies an algebraic expression step by step: expands brackets, combines like terms, cancels common factors in rational expressions and evaluates at given values.
Found a mistake or something missing?
If a value looks wrong, a size is missing or you need a feature, write to us and we will fix it.