CalcDuck

GCF and LCM Calculator

GCF and LCM Calculator

Greatest common factor (GCF)
6
Least common multiple (LCM)
36
Numbers entered
2
Prime factorization
NumberPrime factorization
122^2 × 3
182 × 3^2

The greatest common factor (GCF) is the largest number that divides every number in a list evenly, while the least common multiple (LCM) is the smallest number that every number in the list divides into evenly. For 12 and 18, the GCF is 6 and the LCM is 36; for 4 and 6, the GCF is 2 and the LCM is 12.

Tip: “Copy with settings” shares a link that opens this calculator with your numbers already filled in.

How this calculator works

Enter two or more positive whole numbers, separated by commas or spaces, and this calculator returns their greatest common factor (GCF, also called the greatest common divisor or GCD) and least common multiple (LCM), along with a prime factorization table showing exactly why.

GCF is what you use to simplify a fraction to lowest terms; LCM is what you use to find a common denominator when adding fractions with different denominators. Both can be read directly off each number's prime factorization: the GCF takes the lowest power of each shared prime, and the LCM takes the highest power of every prime that appears in any of the numbers.

How do you find the GCF and LCM?

GCF: computed with the Euclidean algorithm — repeatedly replace the larger number with the remainder of dividing it by the smaller, until the remainder is 0.LCM of two numbers: LCM(a, b) = (a × b) ÷ GCF(a, b)LCM of a list: reduce pairwise, LCM(a, b, c) = LCM(LCM(a, b), c)

For very large inputs, the LCM can exceed the range JavaScript can represent as an exact integer (2^53). When that happens, this calculator shows the result in fixed 10-digit scientific precision instead of a misleadingly long digit string.

Worked example: GCF and LCM of 12 and 18

  1. Prime factorize both: 12 = 2² × 3, and 18 = 2 × 3².
  2. GCF takes the lowest power of each shared prime: 2¹ × 3¹ = 6.
  3. LCM takes the highest power of every prime seen: 2² × 3² = 36.
  4. Check: GCF × LCM = 6 × 36 = 216, which equals 12 × 18 = 216, confirming the identity GCF(a,b) × LCM(a,b) = a × b.

Frequently asked questions

What is the difference between GCF and LCM?

GCF (greatest common factor) is the largest number that divides all the given numbers with no remainder. LCM (least common multiple) is the smallest number that all the given numbers divide into with no remainder. GCF is always less than or equal to the smallest input; LCM is always greater than or equal to the largest input.

Does GCF × LCM = a × b always hold?

Only for exactly two numbers. For two numbers a and b, GCF(a,b) × LCM(a,b) = a × b is always true. With three or more numbers, this shortcut does not directly apply, though the LCM can still be found by reducing pairwise through the list.

Why use prime factorization instead of just listing factors?

Listing every factor gets slow for large numbers, while prime factorization only ever needs to check divisibility by primes up to the square root of the number. It also makes GCF and LCM visible at a glance: GCF uses the lowest shared exponent of each prime, LCM uses the highest.

What if two numbers share no common factors?

They are called coprime (or relatively prime), and their GCF is 1. In that case their LCM is simply the product of the two numbers, since there is no overlap to divide out.

How do I find the GCF of three numbers instead of two?

Find the GCF of the first two numbers, then find the GCF of that result and the third number — the same pairwise approach this calculator already uses to find the LCM of a list. For GCF(12, 18, 30): GCF(12, 18) = 6, then GCF(6, 30) = 6, so the GCF of all three is 6.

Sources

Related calculators