GCF & LCM calculator

Greatest common factor and least common multiple. Prime factors and the first multiples in one table.

Report error
GCF
greatest common factor
LCM
least common multiple
LCM / GCF
how far they sit apart

GCF structure

Every input can be written as GCF × an integer.

LIVE
Shared factor structure updates with your inputs.

LCM construction

Prime exponents show why the least common multiple is what it is.

LIVE
The largest exponent for each prime builds the LCM.

Multiples until LCM

kA×kB×k
GCF is the largest integer that divides every input. LCM is the smallest positive integer each input divides.

Prime factorization

NumberPrimes

Integers

Up to 6 whole numbers. Empty boxes are ignored.

The arithmetic structure

Understanding GCF and LCM

Greatest common factor (GCF) and least common multiple (LCM) are not two unrelated tricks. They are two views of the same prime-factor structure. The GCF tells us what several integers can share; the LCM tells us what must be present before all of them can divide a common number. Once that distinction is clear, the formulas stop being rules to memorize and become consequences of the arithmetic itself.

The central idea: when numbers are written as prime powers, GCF chooses the smallest exponent shared by every input, while LCM chooses the largest exponent appearing anywhere in the set.

GCF and LCM from prime factors

Consider 12, 18, and 30. Their prime factorizations are 12 = 2² × 3, 18 = 2 × 3², and 30 = 2 × 3 × 5. The prime 2 appears in all three, but only to the first power in 18 and 30, so the common contribution is 2¹. Likewise, the common contribution of 3 is 3¹. Therefore the GCF is 2 × 3 = 6.

One factorization, two answers
12=3
18=2
30=235
GCF23= 6
LCM5= 180
Greatest common factor
GCF = ∏ pmin(exponents)
Keep only primes present in every input.
Least common multiple
LCM = ∏ pmax(exponents)
Keep every prime that appears in at least one input.

The most important distinction

QuestionGCFLCM
What are we looking for?The largest common divisorThe smallest common multiple
Prime-exponent ruleSmallest exponentLargest exponent
Direction of the ideaWhat can all numbers share?What must a common multiple contain?
Typical useSimplifying, grouping, factoringCommon denominators, repeating cycles

A useful mental model is this: GCF is compression; LCM is completion. GCF removes everything that is not shared. LCM gathers everything necessary to satisfy every divisibility requirement.

Worked example: 12, 18, and 30

Example 01 · Prime-factor method

Step 1. Factor the inputs: 12 = 2² × 3, 18 = 2 × 3², 30 = 2 × 3 × 5.

Step 2. For the GCF, take the minimum exponent for each prime shared by all three: 2¹ × 3¹ = 6.

Step 3. For the LCM, take the maximum exponent for every prime present: 2² × 3² × 5 = 180.

Step 4. Check the meaning: 6 divides 12, 18, and 30; and 180 is divisible by all three.

Why the two-number identity works

For exactly two nonzero integers a and b, there is a remarkably useful identity:

Product identity
GCF(a,b) × LCM(a,b) = |ab|
A powerful independent check for two inputs.
LCM from GCF
LCM(a,b) = |ab| / GCF(a,b)
Useful when the GCF is easier to obtain first.

For 12 and 18, the GCF is 6. Therefore LCM = (12 × 18) / 6 = 36. Notice that 6 × 36 = 216, exactly the same as 12 × 18. With three or more numbers, do not blindly apply the two-number product identity to the entire set; instead, combine values pairwise or use prime exponents.

Three reliable ways to find the answer

1. Prime factorizationBest for understanding the structure and for several inputs. Minimum exponents give GCF; maximum exponents give LCM.
2. Euclidean algorithmEspecially efficient for GCF of two integers. Repeatedly replace the pair with the divisor and the remainder.
3. Listing multiplesVery intuitive for small numbers. Write multiples until the first shared value appears, then stop.
4. Ladder / division methodDivide the numbers by useful primes, carrying numbers down when they are not divisible. The left-side factors build the LCM.

The Euclidean algorithm: the elegant route to GCF

The Euclidean algorithm is one of the oldest and most efficient ideas in elementary number theory. Its power comes from a simple fact: the common divisors of a and b are exactly the common divisors of b and the remainder when a is divided by b.

Example 02 · GCF(252, 105)

252 = 2 × 105 + 42

105 = 2 × 42 + 21

42 = 2 × 21 + 0

The last non-zero remainder is 21, so GCF(252, 105) = 21.

LCM and common denominators

One of the most important practical appearances of LCM is fraction arithmetic. When two fractions have different denominators, addition requires them to be rewritten using a common denominator. Choosing the least common multiple gives the smallest common denominator that works for both.

Example 03 · Adding unlike fractions

For 1/4 + 1/6, the LCM of 4 and 6 is 12.

Convert 1/4 to 3/12 and 1/6 to 2/12.

Therefore 1/4 + 1/6 = 3/12 + 2/12 = 5/12.

GCF as a tool for simplifying fractions

The GCF performs the opposite-looking job. It identifies the largest factor that can be divided out of both numerator and denominator without changing the value of the fraction.

Example 04 · Simplifying 24/36

GCF(24, 36) = 12.

Divide both terms by 12: 24 ÷ 12 = 2 and 36 ÷ 12 = 3.

So 24/36 = 2/3.

Coprime numbers and useful edge cases

Two integers are coprime when their GCF is 1. They do not need to be prime themselves: 8 and 15 are coprime even though both are composite. For coprime positive integers a and b, the LCM is simply a × b.

CaseGCFLCMInterpretation
8 and 151120Coprime
12 and 18636Several prime factors shared
12 and 361236One number divides the other
1 and 251251 changes neither common multiple nor structure

For negative inputs, the common-factor and common-multiple structure is normally handled through absolute values. Zero requires more care: GCF(a, 0) is |a| for a nonzero integer, while LCM involving zero is convention-dependent and should not be treated casually. This calculator therefore works with nonzero whole-number inputs.

A compact method worth remembering

  1. Factor the numbers if you want the clearest structural picture.
  2. For GCF, go downward. Keep only primes every number contains, using the smallest exponent.
  3. For LCM, go upward. Keep every prime that appears, using the largest exponent.
  4. Check the result. GCF must divide every input; LCM must be divisible by every input.

FAQ

Is GCF the same as GCD?

Yes. Greatest Common Factor and Greatest Common Divisor describe the same mathematical quantity. “GCD” is especially common in higher mathematics and computer science.

What is the difference between a factor and a multiple?

A factor divides a number exactly. A multiple is produced by multiplying the number by an integer. GCF searches among shared factors; LCM searches among shared multiples.

Can the GCF be larger than the smallest input?

No. Every common factor must divide the smallest positive input, so the GCF cannot exceed it.

Can the LCM be smaller than the largest input?

For positive integers, no. Every input divides the LCM, so the LCM is at least as large as the largest input.

Why does the LCM use the largest prime exponent?

Because the common multiple must contain enough copies of every prime to be divisible by each input. The largest exponent is the minimum amount that satisfies the strongest requirement.

Which method should I use by hand?

For small numbers, listing factors or multiples is intuitive. For several numbers, prime factorization is systematic. For the GCF of two large integers, the Euclidean algorithm is usually the cleanest route.