LCM & GCD Calculator
Calculate the Least Common Multiple (LCM) and Greatest Common Divisor (GCD) of two or more numbers instantly, with step-by-step prime factorization.
Least Common Multiple (LCM)
Enter two or more positive integers separated by commas or spaces.
How to Use This Tool
- Choose LCM or GCD/HCF using the mode tabs.
- Enter two or more positive integers, separated by commas or spaces.
- The result updates instantly as you type.
- Review the prime factorization breakdown shown below the result for each number entered.
Formula & How It Works
GCD (Euclidean Algorithm)
GCD(a, b) = GCD(b, a mod b), until b = 0Repeatedly replace the larger number with the remainder of dividing it by the smaller number, until the remainder is zero — the last non-zero remainder is the GCD.
LCM from GCD
LCM(a, b) = |a × b| / GCD(a, b)Once the GCD of two numbers is known, the LCM is found by dividing the product of the numbers by their GCD.
Multiple Numbers
LCM(a, b, c, …) = LCM(LCM(a, b), c, …)For more than two numbers, the LCM (or GCD) is computed by combining the numbers pairwise, left to right.
Practical Examples & Common Use Cases
Example: GCD of 12 and 18
GCD(12, 18): 18 mod 12 = 6, then 12 mod 6 = 0, so GCD(12, 18) = 6.
Example: LCM of 4 and 6
GCD(4, 6) = 2, so LCM(4, 6) = (4 × 6) / 2 = 24 / 2 = 12.
Example: LCM of 12, 18, and 24
LCM(12, 18) = 36, then LCM(36, 24) = 72, so LCM(12, 18, 24) = 72.
Frequently Asked Questions
The Greatest Common Divisor (GCD), also called HCF or GCF, is the largest positive integer that divides all of the given numbers. For example, GCD(12, 18) = 6.
The Least Common Multiple (LCM) is the smallest positive integer that is divisible by all the given numbers. For example, LCM(4, 6) = 12.
For two numbers a and b: LCM(a, b) = (a × b) / GCD(a, b). Knowing one lets you quickly find the other.
LCM is used when adding or subtracting fractions (to find the common denominator), and for scheduling problems like finding when recurring events coincide.
Related Tools
Prime Number Checker
Check if a number is prime, find its prime factorization, and list all prime numbers within a range.
CalculatorsFraction Calculator
Add, subtract, multiply, and divide fractions instantly. Get simplified results with step-by-step explanations. Supports mixed numbers.
CalculatorsExponent / Power Calculator
Calculate any base raised to any exponent. Supports negative and fractional exponents, scientific notation, and powers tables.
Calculators