Skip to content
Calcendium

Search calculators

Calculators

GCD and LCM Calculator with Prime Factorization

Find the greatest common divisor and least common multiple of up to four whole numbers, with their prime factorizations.

  • Calculated in your browser — inputs are never sent to Calcendium
  • All results are estimates
  • Last reviewed

Calculator

Whole numbers

Optional. Leave empty or 0 to skip.

Optional. Leave empty or 0 to skip.

Results

Greatest common divisor (GCD)

Estimate

6

For 12, 18.

Least common multiple (LCM)
36

Prime factorization

12
2² × 3
18
2 × 3²
Greatest common divisor (GCD)
2 × 3
Least common multiple (LCM)
2² × 3²

The GCD takes every prime the numbers share at its lowest power; the LCM takes every prime at its highest power.

On this page

How the GCD and LCM are found

The greatest common divisor (GCD, also called the greatest common factor) is the largest whole number that divides every number without a remainder. The least common multiple (LCM) is the smallest whole number that every number divides into. Both are part of the Common Core standards for grade 6; the notation follows the NIST Digital Library of Mathematical Functions.

GCD and LCM
gcd(a, b) = gcd(b, a mod b), until the remainder is 0
lcm(a, b) = a × b ÷ gcd(a, b)
a, b
Whole numbers of 1 or more
a mod b
The remainder of a ÷ b

The calculator uses Euclid's algorithm above and, for three or four numbers, applies it to two at a time. It also shows each number as a product of primes, the method usually taught at school: the GCD takes the primes all numbers share at their lowest power, the LCM every prime at its highest power.

Worked example

GCD and LCM of 84 and 120
842² × 3 × 7
1202³ × 3 × 5
GCDshared primes, lowest powers2² × 3 = 12
LCMall primes, highest powers2³ × 3 × 5 × 7 = 840

Check: 84 × 120 ÷ 12 = 840. For three numbers, gcd(4, 6, 10) = 2 and lcm(4, 6, 10) = 60.

How to read your results

  • GCD is the largest size you can split every number into equal groups by. With the defaults, 12 and 18 share 6.
  • LCM is the first number every one of them reaches when counting in its own steps: 36 for the defaults. It is the least common denominator when adding fractions.
  • Coprime numbers share no prime: gcd(8, 15) = 1, so their LCM is simply 8 × 15 = 120.

Adding fractions with different denominators? The fraction calculator finds the common denominator and simplifies the answer for you.

Assumptions

  • Two to four whole numbers from 1 to 1,000,000,000.
  • An empty or 0 third or fourth field is ignored.
  • All arithmetic is exact, including LCMs far larger than the inputs.

Limitations

  • Negative numbers and decimals are not accepted.
  • At most four numbers at a time; for more, combine the results: gcd(a, b, c, d, e) = gcd(gcd(a, b, c, d), e).
  • Very long prime factorizations of large numbers may wrap onto several lines.

Frequently asked questions

What is the difference between GCD and LCM?

The GCD divides into all the numbers; the LCM is divided by all of them. For 12 and 18, the GCD is 6 and the LCM is 36.

Is the GCF the same as the GCD?

Yes. Greatest common factor (GCF), greatest common divisor (GCD) and highest common factor (HCF) are three names for the same number.

How are the GCD and LCM related?

For two numbers, GCD × LCM = a × b. For 84 and 120: 12 × 840 = 10,080.

Sources

Definitions and rules referenced on this page. Calcendium is not affiliated with these publishers.

  1. Common Core State Standards for Mathematics, Grade 6: The Number System

    Common Core State Standards Initiative (NGA Center and CCSSO) · United States · Checked October 25, 2026

    Dividing fractions by fractions (6.NS.A.1), and finding the greatest common factor and the least common multiple of whole numbers (6.NS.B.4).

  2. NIST Digital Library of Mathematical Functions, §27.1: Functions of Number Theory, Special Notation

    National Institute of Standards and Technology · International · Checked October 25, 2026

    The greatest common divisor (m, n) of two or more integers; numbers whose greatest common divisor is 1 are relatively prime (coprime).