Back to calculators

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.

Need to add, subtract, or simplify fractions with common denominators? Use our Fraction Calculator to calculate exact rational arithmetic, LCDs, and mixed numbers.
Open Fraction Calculator →
Calculation Mode

Compute both LCM and GCD simultaneously with verified product identity (a × b = GCD × LCM).

First integer

Second integer

Calculated Result
GCD: 6 | LCM: 36

GCD & LCM Results

Calculation: 1. GCD by Euclidean Algorithm: GCD(12, 18) = 6. 2. LCM by GCD-first division: (|12| ÷ 6) × |18| = 2 × 18 = 36. 3. Product Identity Verification: |12| × |18| = 216 = GCD (6) × LCM (36).
Product Identity: For any two positive integers, their product always equals the product of their GCD and LCM: a × b = GCD(a, b) × LCM(a, b).
Breakdown & Metrics
Least Common Multiple (LCM)36
Greatest Common Divisor (GCD)6
Product Identity12 × 18 = 6 × 36 = 216

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

LCM(a, b) = |a|GCD(a, b) × |b|

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.

When to use: Use when finding common denominators for adding fractions or synchronizing recurring events.

Example: For 12 and 18: GCD(12, 18) = 6. LCM = (12 / 6) × 18 = 2 × 18 = 36.

2. Greatest Common Divisor (GCD / HCF) Formula

GCD(a, b) = GCD(b, a \bmod b)

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.

When to use: Use when simplifying fractions, factoring polynomials, or partitioning quantities equally.

Example: For 12 and 18: 18 mod 12 = 6, then 12 mod 6 = 0. Therefore GCD = 6.

3. Two-Number Product Identity

a × b = GCD(a, b) × LCM(a, b)

For any two positive integers, the product of their GCD and LCM strictly equals the product of the two original numbers.

When to use: Use to verify calculations or quickly find LCM when GCD is already known.

Example: For 12 and 18: 12 × 18 = 216. GCD(12, 18) × LCM(12, 18) = 6 × 36 = 216.

4. Multi-Number Associative Reduction

LCM(a, b, c) = LCM(LCM(a, b), c)

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.

When to use: Use when solving scheduling problems or finding common multiples for 3 or more variables.

Example: For 12, 18, 24: LCM(12, 18) = 36, then LCM(36, 24) = 72.

Practical Calculation Examples

Real-world scenarios illustrating step-by-step numbers, inputs, and verified outputs.

Example 1: LCM & GCD of 12 and 18

Compute both GCD and LCM for 12 and 18.

ResultGCD: 6 | LCM: 36

Example 2: Coprime Numbers 8 and 15

Find GCD and LCM for coprime integers 8 and 15.

ResultGCD: 1 | LCM: 120

Example 3: One Number Divides Another (6 and 24)

Compute GCD and LCM when one number is a multiple of the other.

ResultGCD: 6 | LCM: 24

Example 4: Three Numbers (12, 18, 24)

Compute multi-number GCD and LCM for 12, 18, and 24.

ResultGCD: 6 | LCM: 72

Example 5: Four Numbers (15, 20, 30, 45)

Compute multi-number GCD and LCM for four integers.

ResultGCD: 5 | LCM: 180

Example 6: Zero Edge Case (0 and 12)

Calculate GCD and LCM with a zero input.

ResultGCD: 12 | LCM: 0

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 academic, financial, and mathematical computation tools.