LCM & GCD Calculator
Find the Least Common Multiple (LCM) and Greatest Common Divisor (GCD / HCF) of two or more numbers with step-by-step solutions.
Compute both LCM and GCD simultaneously with verified product identity (a × b = GCD × LCM).
First integer
Second integer
GCD & LCM Results
How LCM and GCD Are Calculated
Pure integer mathematical formulas using the Euclidean algorithm, GCD-first LCM division, and product identities.
1. Least Common Multiple (LCM) Formula
The Least Common Multiple is the smallest positive integer divisible by both a and b. Dividing a by GCD(a, b) first prevents intermediate overflow before multiplying by b.
2. Greatest Common Divisor (GCD / HCF) Formula
The Greatest Common Divisor (also known as Highest Common Factor or HCF) is the largest integer dividing both terms without a remainder. The Euclidean algorithm repeatedly replaces (a, b) with (b, a mod b) until the remainder is zero.
3. Two-Number Product Identity
For any two positive integers, the product of their GCD and LCM strictly equals the product of the two original numbers.
4. Multi-Number Associative Reduction
To find the GCD or LCM of three or more numbers, evaluate them sequentially in pairs: find the result of the first two numbers, then combine that result with the next number.
Step-by-Step Guide: Finding LCM & GCD with the Euclidean Algorithm
Modern computation avoids slow trial factoring of huge integers by using Euclid's division algorithm first to find GCD, then deriving LCM safely.
- 1
Compute GCD via Euclidean Remainders
Repeatedly replace (a, b) with (b, a mod b) until the remainder reaches 0. The last non-zero divisor is the Greatest Common Divisor (HCF).
- 2
Derive Two-Number LCM Without Overflow
Instead of multiplying |a × b| first (which can overflow large numbers), compute (|a| ÷ GCD(a, b)) × |b| so intermediate numbers stay small.
- 3
Iterate Pairwise for Lists of 3+ Numbers
Apply associativity across arrays: LCM(a, b, c) = LCM(LCM(a, b), c) and GCD(a, b, c) = GCD(GCD(a, b), c).
LCM vs. GCD (HCF): Mathematical Properties & Benchmarks
Core identities and worked benchmarks comparing Least Common Multiple and Greatest Common Divisor.
| Input Pair / Set | GCD (HCF) | LCM | Notable Mathematical Relationship |
|---|---|---|---|
| 12 and 18 | 6 | 36 | 12 × 18 = 216; 6 × 36 = 216 (Product Identity holds) |
| 8 and 15 | 1 | 120 | Coprime integers (GCD = 1): LCM equals product |8 × 15| |
| 14 and 42 | 14 | 42 | When a divides b evenly, GCD = |a| and LCM = |b| |
| 12, 18, and 24 | 6 | 72 | 3+ numbers: LCM × GCD (432) ≠ 12×18×24 (5,184) |
| 0 and 9 | 9 | 0 | Zero has infinitely many divisors, so GCD(0, b) = |b| and LCM = 0 |
Note: The well-known product law LCM(a, b) × GCD(a, b) = |a × b| holds strictly for two integers, NOT three or more.
Edge Cases & Number Theory Rules
Two-Number vs. Multi-Number Product Identity
Never assume LCM(a, b, c) = (a × b × c) ÷ GCD(a, b, c). For example, LCM(2, 4, 6) = 12 and GCD(2, 4, 6) = 2, yet 2×4×6 = 48 ≠ 12×2.
Coprime Numbers
Numbers sharing no common prime factors (like 15 and 28, or any two distinct primes) are coprime with GCD = 1 and LCM = a × b.
Negative Integer Convention
Number theory defines both GCD and LCM as non-negative quantities computed from absolute values |a| and |b|.
LCM & GCD Calculator — Worked Examples
Real-world scenarios and verified benchmark inputs for the LCM & GCD Calculator.
Example 1: LCM & GCD of 12 and 18
Compute both GCD and LCM for 12 and 18.
Example 2: Coprime Numbers 8 and 15
Find GCD and LCM for coprime integers 8 and 15.
Example 3: One Number Divides Another (6 and 24)
Compute GCD and LCM when one number is a multiple of the other.
Example 4: Three Numbers (12, 18, 24)
Compute multi-number GCD and LCM for 12, 18, and 24.
Example 5: Four Numbers (15, 20, 30, 45)
Compute multi-number GCD and LCM for four integers.
Example 6: Zero Edge Case (0 and 12)
Calculate GCD and LCM with a zero input.
LCM & GCD Calculator — Frequently Asked Questions
Clear answers to common questions about finding the Least Common Multiple, Greatest Common Divisor, HCF, coprime numbers, and negative inputs.
What is an LCM calculator?
An LCM calculator is a mathematical computation tool that determines the Least Common Multiple (the smallest positive integer divisible by all inputs) and Greatest Common Divisor (GCD/HCF) for two or more integers using the Euclidean algorithm and prime-reduction steps.
How do I find LCM using a calculator?
To find the LCM using this calculator, select 'LCM of Two Numbers' or 'Multiple Numbers', enter your positive integers, and the calculator instantly computes the exact LCM, prime factors, and step-by-step reduction.
How do I calculate the LCM of two numbers?
To calculate the LCM of two numbers a and b, divide the absolute value of a by their Greatest Common Divisor and multiply by b: LCM(a, b) = (|a| ÷ GCD(a, b)) × |b|. For example, for 12 and 18, GCD is 6, so LCM = (12 ÷ 6) × 18 = 36.
What is the difference between LCM and HCF/GCD?
LCM (Least Common Multiple) is the smallest positive number that is a multiple of all given numbers (greater than or equal to the largest number). HCF/GCD (Highest Common Factor / Greatest Common Divisor) is the largest integer that divides all given numbers evenly (less than or equal to the smallest non-zero number).
How do I find LCM and HCF together?
Select the 'Both LCM & GCD' mode and enter your two numbers. The calculator evaluates their GCD using the Euclidean division algorithm, then applies the product identity LCM = (a × b) ÷ GCD to display both values side by side with the verification product.
How are LCM and GCD related for two numbers?
For any two positive integers a and b, the product of their GCD and LCM strictly equals the product of the numbers: a × b = GCD(a, b) × LCM(a, b). This fundamental relationship applies to two-number pairs.
How do you find the LCM of three or more numbers?
You can find the LCM of multiple numbers by calculating the LCM of the first two numbers, and then finding the LCM of that result with the third number: LCM(a, b, c) = LCM(LCM(a, b), c). This pairwise reduction continues for all numbers.
What does it mean if two numbers are coprime?
Two numbers are coprime (or relatively prime) if their Greatest Common Divisor is 1. When two numbers are coprime, their LCM is simply their direct product (LCM = a × b).
Related Calculators
Explore connected math and related computation tools.