GCF and LCM Calculator

GCF and LCM Calculator

Emerging AI Skill PRO

Enter Calculation

Formula

GCF(a,b)andLCM=a×bGCF(a,b)\text{GCF}\left(\text{a},\ \text{b}\right) \quad\text{and}\quad \text{LCM} = \frac{\text{a} \times \text{b}}{\text{GCF}\left(\text{a},\ \text{b}\right)}
Usage stats

Advertisement

Results

Greatest Common Factor (GCF)
6
GCF(12, 18)
Least Common Multiple (LCM) 36
Greatest Common Factor (GCF) 6
Product (a × b) 216

Report an error on this page

What is the GCF and LCM Calculator?

This calculator finds two fundamental quantities for any pair of whole numbers: the Greatest Common Factor (GCF) — also called the greatest common divisor (GCD) — and the Least Common Multiple (LCM). The GCF is the largest number that divides both inputs evenly, while the LCM is the smallest number that both inputs divide into evenly. These appear constantly when simplifying fractions, finding common denominators, and solving number-theory problems.

How to use it

Enter your two whole numbers in the First number and Second number fields and submit. The calculator returns the GCF in the hero box, plus the LCM and the product of the two numbers in the table below. Both values are computed instantly using Euclid's algorithm, which is fast even for very large numbers.

The formula explained

The GCF is computed with Euclid's algorithm: repeatedly replace the pair \((a,\ b)\) with \((b,\ a \bmod b)\) until the second value reaches zero; the remaining value is the GCF. Once the GCF is known, the LCM follows from a neat identity:

$$\text{LCM}(a,\ b) = \frac{a \times b}{\text{GCF}(a,\ b)}$$

This works because the product of two numbers always equals the product of their GCF and LCM.

Advertisement
Venn diagram of prime factors shared and unique between two numbers showing GCF and LCM
GCF is the product of shared prime factors; LCM covers all factors of both numbers.

Worked example

Take \(a = 12\) and \(b = 18\). Euclid's algorithm: \(18 \bmod 12 = 6\), then \(12 \bmod 6 = 0\), so the GCF \(= 6\). The LCM is then $$\frac{12 \times 18}{6} = \frac{216}{6} = 36.$$ So \(\text{GCF}(12,\ 18) = 6\) and \(\text{LCM}(12,\ 18) = 36\).

Flowchart of Euclid's algorithm repeatedly replacing larger number with remainder
Euclid's algorithm finds the GCF by repeated division until the remainder is zero.

More Worked Examples: Coprime, Multiple and Large Pairs

Each example uses Euclid's algorithm: repeatedly replace the pair (a, b) with (b, a mod b) until the remainder is 0. The last non-zero remainder is the GCF. Then \(\text{LCM} = \frac{a \times b}{\text{GCF}}\).

Example 1: A coprime pair (8 and 15)

  1. 15 mod 8 = 7 (since 15 = 1 × 8 + 7)
  2. 8 mod 7 = 1 (since 8 = 1 × 7 + 1)
  3. 7 mod 1 = 0, so the GCF is 1.

$$\text{LCM} = \frac{8 \times 15}{1} = \frac{120}{1} = 120$$

GCF(8, 15) = 1 and LCM = 120. Because the GCF is 1, the LCM equals the product of the two numbers.

Example 2: One number is a multiple of the other (6 and 24)

  1. 24 mod 6 = 0 (since 24 = 4 × 6), so the algorithm stops immediately.
  2. The last non-zero divisor is 6, so the GCF is 6.

$$\text{LCM} = \frac{6 \times 24}{6} = \frac{144}{6} = 24$$

GCF(6, 24) = 6 and LCM = 24. When one number divides the other, the GCF is the smaller number and the LCM is the larger number.

Example 3: A larger pair (252 and 105)

  1. 252 mod 105 = 42 (since 252 = 2 × 105 + 42)
  2. 105 mod 42 = 21 (since 105 = 2 × 42 + 21)
  3. 42 mod 21 = 0 (since 42 = 2 × 21), so the GCF is 21.

$$\text{LCM} = \frac{252 \times 105}{21} = \frac{26460}{21} = 1260$$

GCF(252, 105) = 21 and LCM = 1260.

Advertisement

Interpreting Your GCF and LCM Results

  • GCF = 1: the numbers are coprime (relatively prime). They share no common factor other than 1, such as 8 and 15. Their LCM is exactly their product.
  • GCF equals the smaller number: the smaller number divides the larger one evenly. For 6 and 24 the GCF is 6, and the LCM is the larger number, 24.
  • LCM equals the product only when GCF = 1. In general, \(\text{GCF} \times \text{LCM} = a \times b\), so any common factor reduces the LCM below the product (for 252 and 105, the LCM 1260 is far smaller than 26460).

Using the GCF: simplifying fractions

Divide the numerator and denominator by their GCF to reduce a fraction to lowest terms. For 252/105, the GCF is 21, so \(\frac{252 \div 21}{105 \div 21} = \frac{12}{5}\).

Using the LCM: common denominators and repeating cycles

The LCM of the denominators is the least common denominator. To add 1/6 + 1/15, the LCM of 6 and 15 is 30, so \(\frac{5}{30} + \frac{2}{30} = \frac{7}{30}\).

The LCM also tells you when repeating cycles line up again. If one event repeats every 6 minutes and another every 8 minutes, they coincide every LCM(6, 8) = 24 minutes.

FAQ

What's the difference between GCF and GCD? They are the same thing — "greatest common factor" and "greatest common divisor" are interchangeable terms.

Can I enter decimals? GCF and LCM are defined for whole numbers (integers). Decimals are rounded down to integers before calculation.

What if one number is zero? Mathematically the GCF of any number and 0 is that number, but the LCM is undefined; use positive whole numbers for meaningful results.

Last updated:

Most popular in Math and Statistics

View all Math and Statistics calculators