A comprehensive guide to finding the GCD and LCM of any set of numbers using multiple methods.
The Greatest Common Divisor (GCD) and Least Common Multiple (LCM) are two of the most frequently used concepts in number theory and practical mathematics. Whether you are simplifying fractions, finding common denominators, scheduling events, or solving Diophantine equations, understanding how to compute the GCD and LCM efficiently is essential. This guide explains both concepts from scratch, walks through multiple calculation methods with worked examples, and connects them with the fundamental relationship that ties them together. For instant results, use our free GCD and LCM calculator.
The Greatest Common Divisor (also called Greatest Common Factor or GCF) of two or more numbers is the largest positive integer that divides each of the numbers without leaving a remainder.
For example, the divisors of 12 are {1, 2, 3, 4, 6, 12} and the divisors of 18 are {1, 2, 3, 6, 9, 18}. The common divisors are {1, 2, 3, 6}, and the greatest of these is 6. So GCD(12, 18) = 6.
The GCD is useful whenever you need to reduce a fraction to its simplest form. For instance, to simplify 12/18, divide both numerator and denominator by GCD(12, 18) = 6, giving 2/3.
The Least Common Multiple of two or more numbers is the smallest positive integer that is a multiple of each of the numbers.
For example, the multiples of 4 are {4, 8, 12, 16, 20, 24, ...} and the multiples of 6 are {6, 12, 18, 24, 30, ...}. The common multiples are {12, 24, 36, ...}, and the least of these is 12. So LCM(4, 6) = 12.
The LCM is essential when you need to find a common denominator for adding or subtracting fractions, or when scheduling events that repeat at different intervals.
This method works fine for small numbers but becomes impractical for large ones. That is where the Euclidean algorithm shines.
The Euclidean algorithm is one of the oldest and most efficient algorithms in mathematics. It is based on the principle that GCD(a, b) = GCD(b, a mod b), and it terminates when the remainder reaches zero.
✅ GCD(252, 105) = 21
The Euclidean algorithm is extremely fast — it runs in O(log min(a,b)) time, making it practical even for numbers with hundreds of digits. This is the method used by most online GCD calculators.
Another approach is to break each number down into its prime factors and then combine them appropriately.
For any two positive integers a and b:
This is a powerful shortcut. If you already know the GCD, you can find the LCM without prime factorization:
Simplify the fraction 48/64.
Add the fractions 5/6 and 7/9.
A bus arrives every 15 minutes and a train arrives every 20 minutes. They both arrive together at 8:00 AM. When will they next arrive together?
Both concepts extend naturally to three or more numbers. For the GCD, you can apply the Euclidean algorithm pairwise: GCD(a, b, c) = GCD(GCD(a, b), c). For the LCM, similarly: LCM(a, b, c) = LCM(LCM(a, b), c).
Our free calculator supports 2 to 10 numbers with step-by-step solutions using the Euclidean algorithm.
No. The GCD of two numbers cannot exceed the smaller of the two numbers. By definition, the GCD must divide both numbers evenly, so it must be less than or equal to each of them.
If two numbers are both prime and different from each other, their GCD is always 1. Two numbers with a GCD of 1 are called coprime or relatively prime.
No, this formula only applies to two numbers. For three or more numbers, you must compute the GCD and LCM separately using the pairwise approach.
They are the same thing. GCD stands for "Greatest Common Divisor" and GCF stands for "Greatest Common Factor." Different textbooks and regions use different terms, but the concept is identical.
The GCD is always positive. When working with negative numbers, simply ignore the signs and apply the algorithm to the absolute values. GCD(−12, 18) = GCD(12, 18) = 6.
Find GCD and LCM for up to 10 numbers instantly
Solve any quadratic equation with step-by-step solutions
Calculate percentages, changes, and differences
Complete guide with worked examples