GCF and LCM Calculator

Enter two or more positive integers, separated by commas or spaces, to find the greatest common factor (also called GCD or HCF) and the least common multiple. A prime-factorization mode shows the prime factors of each number, which is how the GCF and LCM are built. There is not a separate prime-factorization page, so this one tool covers both jobs without competing with itself.

By Rashid MehmoodLast updated and reviewed Free, no sign-up

GCF, LCM and prime factorization calculator

–

How to use the gcf and lcm calculator – with prime factorization

  1. Choose a mode. Both GCF and LCM (default), GCF only, LCM only, or prime factorization.
  2. Enter the integers. Type two or more positive whole numbers, separated by commas or spaces, for example 12, 18, 30.
  3. Calculate. The result lists the GCF, the LCM, and the prime factorization of each input.
  4. Check the factors. The factorization is the reason the GCF and LCM have the values they do — compare it with your own work if you need to show steps.
Embed this calculator

Paste this iframe on your own site. The embed view already includes a visible “Calculator by CalcTen” credit, which must stay visible. See the developers page for the conditions.

Formula

If n = 2a × 3b × 5c × … and m = 2A × 3B × 5C × …
then GCF(n, m) = 2min(a,A) × 3min(b,B) × …
and LCM(n, m) = 2max(a,A) × 3max(b,B) × …
For two numbers, LCM(n, m) = n × m ÷ GCF(n, m)

The last identity is a useful check, but the prime method extends cleanly to three or more numbers, which is why the default example uses 12, 18 and 30.

Worked examples

12, 18 and 30. Factorizations: 12 = 2² × 3, 18 = 2 × 3², 30 = 2 × 3 × 5. Minimum powers: 2¹ and 3¹, so GCF = 6. Maximum powers: 2², 3² and 5¹, so LCM = 4 × 9 × 5 = 180. Check: the pairwise formula is for two inputs at a time, so for three numbers stay with the prime method.

8 and 9 (coprime). 8 = 2³, 9 = 3². GCF = 1, LCM = 72.

14 and 35. 14 = 2 × 7, 35 = 5 × 7. GCF = 7, LCM = 70.

Use cases and common mistakes

Use GCF to simplify a fraction or to cut a length into equal pieces, and LCM to find a common period or a common denominator. Common mistakes include listing 1 as a prime factor, stopping a factorization at a composite (such as leaving 9 in the product), and taking products of the numbers without dividing by the GCF when you use the two-number identity. For ratios, see the ratio calculator. Everyday arithmetic is on the basic calculator, and a scientific keypad is at the scientific calculator.

Limitations

Inputs must be positive integers of a size the page can factor in the browser. Very large integers may be rejected. The tool shows the result and the factorizations; it is not a step-by-step long-division lesson.

Frequently asked questions

What is the GCF and LCM of 12, 18 and 30?

12 = 2² × 3, 18 = 2 × 3², 30 = 2 × 3 × 5. The GCF takes the minimum powers: 2 × 3 = 6. The LCM takes the maximum powers: 2² × 3² × 5 = 180.

Is GCF the same as GCD or HCF?

Yes. Greatest common factor, greatest common divisor and highest common factor are the same idea. This page uses GCF in the title and accepts all three names in the explanation.

How does prime factorization give the GCF and LCM?

Write each number as a product of primes. The GCF multiplies each prime raised to the smallest exponent that appears in every factorization. The LCM uses the largest exponent that appears in any factorization.

Can I enter only one number?

Prime-factorization mode can show the factors of a single integer. GCF and LCM need at least two numbers.

Do you allow 0 or negative numbers?

No. These definitions are for positive integers. Zero has an awkward relationship with LCM, and signs are ignored in ordinary school GCF/LCM work, so they are rejected here.

What if the numbers are coprime?

If the GCF is 1, the numbers share no prime factor greater than 1. The LCM is then just their product (for two numbers).

Is there a separate prime factorization calculator?

No. Prime factorization is a mode of this page, to avoid two overlapping URLs for the same integers.

Sources and references

About this calculator

Written and maintained by Rashid Mehmood, founder of CalcTen. The formulas are unit-tested against hand-worked examples, and the content is reviewed whenever product sizes or guidance change. Last updated and reviewed 15 November 2026. See our editorial policy. If you spot a mistake, report it.

Results are calculated from the numbers you enter and shown with the working. Rounding is applied only when displaying results. Grade and GPA scales, and weighting rules, vary by school, so confirm with your institution. Read the disclaimer.

Calculator by CalcTen — free online calculators.