# LCM & GCD Calculator

URL: https://hifreetools.com/calculators/lcm-gcd-calculator

> Enter one positive integer per row to find the greatest common divisor (GCD) and least common multiple (LCM). Add or remove rows, or paste a list separated by commas, spaces, newlines, tabs or semicolons.

## Quick answer

The GCD (greatest common divisor) is the largest integer that divides every number with no remainder, and the LCM (least common multiple) is the smallest positive integer that every number divides into evenly. For two numbers a and b the key identity is LCM(a, b) = (a × b) / GCD(a, b); for example GCD(12, 18) = 6, so LCM(12, 18) = (12 × 18) / 6 = 216 / 6 = 36. For longer lists both values are folded pairwise: GCD(a, b, c) = GCD(GCD(a, b), c) and the same nesting applies to the LCM.

## Formula

- GCD(a, b) = GCD(b, a mod b), GCD(a, 0) = a
- LCM(a, b) = (a × b) ÷ GCD(a, b)
- GCD(a, b, c, …) = GCD(GCD(a, b), c, …); LCM folds the same way

## Inputs

- Your numbers (separated by commas); default 12, 18

## Worked examples (computed by the page's own function)

- Your numbers (separated by commas) = 12, 18 → GCD (GCF) — greatest common divisor = 6, LCM — least common multiple = 36, Numbers entered = 2  (GCD(12, 18) = 6; LCM = (12 × 18) ÷ 6 = 36)
- Your numbers (separated by commas) = 8, 12, 20 → GCD (GCF) — greatest common divisor = 4, LCM — least common multiple = 120, Numbers entered = 3  (GCD(8, 12, 20) = 4; LCM(8, 12, 20) = 120)
- Your numbers (separated by commas) = 4, 6, 8, 12 → GCD (GCF) — greatest common divisor = 2, LCM — least common multiple = 24, Numbers entered = 4  (GCD(4, 6, 8, 12) = 2; LCM(4, 6, 8, 12) = 24)

## Verification

Checked against 17 reference cases (expected values computed independently). Reviewed 2026-10-27. Latest change 2026-10-28: Moved to the schema renderer with a sourced ledger. The numbers go in one text box (commas, semicolons, tabs, new lines or spaces between them) instead of one row per number; same exact-integer limit of 9,007,199,254,740,991 for every input and the LCM.

## FAQ

**What is the difference between GCD and LCM?**
The GCD (greatest common divisor, also called GCF or HCF) is the largest number that divides all of your inputs without a remainder, so it is always ≤ the smallest input. The LCM (least common multiple) is the smallest positive number that all of your inputs divide into evenly, so it is always ≥ the largest input. For 12 and 18 the GCD is 6 and the LCM is 36.

**Is GCD the same as GCF or HCF?**
Yes. GCD (greatest common divisor), GCF (greatest common factor), and HCF (highest common factor) are three names for the exact same quantity. Different textbooks and countries prefer different abbreviations, but they all mean the largest integer that divides every number in the set.

**How does the calculator find the GCD so fast?**
It uses Euclid's algorithm, which repeatedly replaces the larger number with the remainder of dividing the pair until one of them is zero — the other value is then the GCD. It is dramatically faster than listing factors and works in just a handful of steps even for very large numbers.

**Why isn't the LCM just all the numbers multiplied together?**
Because the product double-counts any shared factors. For 12 and 18 the product is 216, but both share a factor of 6, so the true LCM is 216 ÷ 6 = 36. The correct formula is LCM(a, b) = (a × b) / GCD(a, b), which removes the overlap.

**Can I find the LCM or GCD of more than two numbers?**
Yes. Add rows or paste a list separated by commas, spaces, newlines, tabs or semicolons. Do not include thousands separators. The tool combines values pairwise, independent of their order. Each input and the final LCM must be at most 9,007,199,254,740,991; very long lists may take time.

**What happens if I enter a decimal, a fraction, or zero?**
This tool accepts positive integer values and ignores blank rows. Integer-valued decimal or exponent notation such as 12.0 or 1.2e1 is accepted. Non-integer values, fractions such as 3/4, zero and negatives are rejected. If you scale quantities to integers, interpret the result in that same scale.


## Sources

- [Wikipedia — Least common multiple](https://en.wikipedia.org/wiki/Least_common_multiple)
- [Wikipedia — Greatest common divisor](https://en.wikipedia.org/wiki/Greatest_common_divisor)
- [Wikipedia — Euclidean algorithm](https://en.wikipedia.org/wiki/Euclidean_algorithm)

Runs in the browser; nothing is uploaded. Cite as: HIFreeTools, "LCM & GCD Calculator", https://hifreetools.com/calculators/lcm-gcd-calculator
