LCM and GCD Calculator

Updated July 2026

Enter two or more whole numbers to find their greatest common divisor (GCD) and least common multiple (LCM) — complete with the prime factorization of each number and a step-by-step breakdown of how the answers are built. Everything runs privately in your browser.

The GCD (greatest common divisor, also called the GCF or greatest common factor) is the largest integer that divides every input. The LCM (least common multiple) is the smallest integer every input divides into. For two numbers they obey the rule lcm(a, b) × gcd(a, b) = a × b.
Separate values with commas or spaces.
Greatest common divisor (GCD / GCF)
Least common multiple (LCM)
Prime factorization of each number
How the GCD & LCM are derived

How this LCM and GCD calculator works

This tool takes any list of two or more positive integers and returns two key quantities. The greatest common divisor (GCD) — identical to the greatest common factor (GCF) or highest common factor (HCF) — is the largest number that divides all of your inputs exactly. The least common multiple (LCM) is the smallest number that every input divides into without a remainder.

The GCD is computed with Euclid's algorithm, which repeatedly replaces the larger number with the remainder of dividing it by the smaller one — gcd(a, b) = gcd(b, a mod b) — until the remainder is zero. The LCM is then found with the identity lcm(a, b) = a × b ÷ gcd(a, b). For longer lists, both operations are folded across the numbers two at a time, so gcd(a, b, c) = gcd(gcd(a, b), c) and likewise for the LCM. The math runs with BigInt internally so the LCM stays exact even when it grows large.

Worked example: for 12 and 18, the prime factorizations are 12 = 2² × 3 and 18 = 2 × 3². The shared factors are 2 × 3 = 6, so the GCD is 6. Combining the highest power of each prime gives 2² × 3² = 36, so the LCM is 36. Checking the rule: 6 × 36 = 216 = 12 × 18. ✔

Reference note: GCD = GCF = HCF, all the same value. The calculator accepts positive whole numbers only; decimals, negatives, zero and non-numeric text trigger a friendly error.

Frequently asked questions

What is the GCD?
The greatest common divisor (GCD) of a set of integers is the largest positive integer that divides every number in the set without a remainder. For example, the GCD of 12 and 18 is 6, the largest number dividing both.
What is the LCM?
The least common multiple (LCM) is the smallest positive integer that every number in the set divides evenly. For example, the LCM of 12 and 18 is 36, the smallest number both divide into.
Is GCF the same as GCD?
Yes. The greatest common factor (GCF) is just another name for the greatest common divisor (GCD); some textbooks call it the highest common factor (HCF). All three refer to the same value.
How do you find the LCM?
For two numbers, the LCM equals their product divided by their GCD: lcm(a, b) = a × b ÷ gcd(a, b). For more than two numbers, take the LCM of the running result with each next number in turn.
How is the GCD calculated using Euclid's algorithm?
Euclid's algorithm repeatedly replaces the larger number with the remainder of dividing it by the smaller one — gcd(a, b) = gcd(b, a mod b) — stopping when the remainder is zero. The last non-zero value is the GCD, with no factoring required.
Can it handle more than two numbers?
Yes. Enter any list of two or more positive integers separated by commas or spaces. The calculator folds the GCD and LCM across the whole list, applying the pairwise rules to every number.
⚡ LCM and GCD Calculator — by larely ↗

Related tools

Scientific Notation Converter

Convert numbers to and from scientific, E and engineering notation.

Slope Calculator

Find the slope, angle, distance and equation of a line from two points.

Speed, Distance & Time Calculator

Solve for speed, distance or time from the other two, in any units.

Density Calculator

Solve density = mass / volume for any of the three, with unit conversion.

Square Root Calculator

Find and simplify square roots, with perfect-square and radical form.

Exponent Calculator

Raise any base to any power, including negative and fractional exponents.

Prime Number Checker

Check if a number is prime and get its prime factorization.

Circle Calculator

Find a circle's radius, diameter, circumference and area from any one value.

Permutation & Combination Calculator

Calculate combinations and permutations for n and r.

Logarithm Calculator

Compute log of any base, plus log10, ln and log2, with change of base.

Factorial Calculator

Calculate n! exactly for any non-negative integer, including huge values.

Fibonacci Calculator

Generate the Fibonacci sequence and find the Nth Fibonacci number.

Browse all 251 free tools →