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.
Worked 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.
Worked 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.
Worked 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.
Worked Example: For 12, 18, 24: LCM(12, 18) = 36, then LCM(36, 24) = 72.

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. 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. 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. 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 / SetGCD (HCF)LCMNotable Mathematical Relationship
12 and 1863612 × 18 = 216; 6 × 36 = 216 (Product Identity holds)
8 and 151120Coprime integers (GCD = 1): LCM equals product |8 × 15|
14 and 421442When a divides b evenly, GCD = |a| and LCM = |b|
12, 18, and 246723+ numbers: LCM × GCD (432) ≠ 12×18×24 (5,184)
0 and 990Zero 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.

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

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.

Browse all Math calculators