Calculator for finding the GCD and LCM of numbers.
Calculator for finding GCD and LCM of numbers. Up to 50 numbers at a time.
Specify the number of numbers:
x
x
Greatest Common Divisor (GCD) - is the largest positive integer that divides each of the given numbers without leaving a remainder.
Least Common Multiple (LCM) - is the smallest number that is divisible by all given numbers without leaving a remainder.
How to find GCD
- Divisor enumeration method
This method can be labor-intensive for large numbers.
The method consists of listing all divisors of the numbers and selecting the largest common divisor.Example:
Let's find GCD for numbers 12 and 18.
Divisors of 12: 1, 2, 3, 4, 6, 12.
Divisors of 18: 1, 2, 3, 6, 9, 18.
Common divisors: 1, 2, 3, 6.
Answer: GCD(12,18) = 6. - Prime factorization
The essence of this method is to represent each number as a product of prime numbers.
This method works well for small numbers and can find GCD for several numbers at once.
Algorithm:
Factor each number using division.
Find all common factors — those factors that appear in each given number.
Among them, select factors with the smallest exponent.
Multiply them together to get the GCD.
Example:
GCD(12,18)
Common factors with the smallest exponents: 21 * 31 = 6Number Factors In exponential form 12 = 2×2×3 = 22 × 31 18 = 2×3×3 = 21 × 32 - Euclidean algorithm
The most convenient method. Well suited for large numbers. But only for two numbers per calculation.
Algorithm:
Divide the larger number by the smaller one and find the remainder.
Divide the smaller number by the remainder from the previous division.
Repeat the process until the remainder becomes zero.
The GCD is the last non-zero remainder.
If the remainder is zero at the first division, then the GCD is the smaller number.
Example:
GCD(12,18) = 6Division Quotient Remainder 18÷12 = 1 6 12÷6 = 2 0
How to find LCM
- Using known GCD
The simplest and most accessible method. However, it requires knowledge of GCD and is only possible for two numbers.
The method is based on the following formula:
Example:
where a and b are given numbers.
Let's find LCM for numbers 12 and 18
First, determine GCD(12,18) = 6
- Prime factorization method
The essence of the method is to factor a number into several prime numbers — factors.
This method is suitable for any number of values.
Example:
Let's find LCM for numbers 12 and 18
Factor these numbers into prime factors:
If there are repeating factors, choose the one with the largest exponent. Such factors are highlighted in green.Number Factors In exponential form 12 = 2×2×3 = 22 × 31 18 = 2×3×3 = 21 × 32
Multiplying all unique factors with the highest exponents together gives the LCM of the given numbers.22 × 32 = 36
Remember that GCD is the largest number, while LCM is, conversely, the smallest.
Linked Calculators
Long Divide,Multiply, Add and Subtract CalculatorMathematics