GCF and LCM Calculator (Greatest Common Factor and LCM)

  • Free
  • No sign-up
  • Works on phones
  • Shows the working
Basic & Scientific#70

GCF & LCM

Greatest common factor and least common multiple of 2–10 numbers, with prime factorizations and Euclid's steps.

This GCF and LCM calculator finds the greatest common factor (GCF, also called the greatest common divisor, GCD, or highest common factor, HCF) and the least common multiple (LCM) of 2 to 10 whole numbers. It shows the prime factorization of each number and, for two numbers, every step of Euclid’s algorithm.

It’s free and needs no sign-up.

GCF and LCM Calculator (Greatest Common Factor and LCM): On a number line the multiples of 4 (top) and of 6 (bottom) first…
On a number line the multiples of 4 (top) and of 6 (bottom) first coincide at 12, then at 24: LCM(4, 6) = 12, and GCF(4, 6) = 2.

How to use it

  1. Enter the numbers separated by commas or spaces, for example 48, 180 or 12 18 30.
  2. Press Calculate.

Definitions

  • The GCF is the largest number that divides all of them exactly.
  • The LCM is the smallest positive number that all of them divide into exactly.

For two numbers they are linked by

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

Method 1: prime factorization

Write each number as a product of primes (the prime factorization calculator does this). Then:

  • GCF: multiply the primes they share, each to the lowest power that appears.
  • LCM: multiply every prime that appears, each to the highest power.

Worked example: 48 and 180

As loaded above: ( 48 = 2^4 times 3 ) and ( 180 = 2^2 times 3^2 times 5 ).

  • GCF: ( 2^2 times 3 = 12 ).
  • LCM: ( 2^4 times 3^2 times 5 = 720 ).

Check: ( 12 times 720 = 8640 = 48 times 180 ). ✔

Method 2: Euclid’s algorithm

Divide the larger number by the smaller and keep the remainder; then divide the previous divisor by that remainder; repeat until the remainder is 0. The last non-zero remainder is the GCF.

Colorful beads on an abacus, a tool for counting and calculations.
aba ÷ bRemainder
18048336
4836112
361230

The GCF is 12. Then ( text{LCM} = frac{48 times 180}{12} = 720 ). Euclid’s algorithm is much faster than listing factors for big numbers.

Worked example: three numbers

For 12, 18 and 30: ( 12 = 2^2 cdot 3 ), ( 18 = 2 cdot 3^2 ), ( 30 = 2 cdot 3 cdot 5 ). The GCF is ( 2 cdot 3 = 6 ) and the LCM is ( 2^2 cdot 3^2 cdot 5 = 180 ).

Word problems

LCM: when things line up again. Hot dogs come in packs of 8 and buns in packs of 12. The smallest number of each you can buy with none left over is ( text{LCM}(8, 12) = 24 ): three packs of hot dogs and two packs of buns.

GCF: splitting into equal groups. You have 24 red and 36 blue marbles and want identical bags with no marbles left over. The most bags you can make is ( text{GCF}(24, 36) = 12 ), each with 2 red and 3 blue.

Fractions

Next, the LCM of the denominators is the least common denominator for adding fractions: ( frac{1}{8} + frac{1}{12} = frac{3}{24} + frac{2}{24} = frac{5}{24} ). The GCF of the numerator and denominator simplifies a fraction: ( frac{48}{180} = frac{48 div 12}{180 div 12} = frac{4}{15} ). See fractions and the fraction calculator.

Common mistakes

  • Mixing up the powers. GCF uses the lowest power of shared primes; LCM uses the highest power of all primes.
  • Including unshared primes in the GCF. 5 divides 180 but not 48, so it is not in the GCF.
  • Multiplying the numbers to get the LCM. ( 48 times 180 ) is a common multiple, but usually not the least one.

Method 3: listing

For small numbers you can simply list. Multiples of 6: 6, 12, 18, 24, 30 … Multiples of 8: 8, 16, 24, 32 … The first one in both lists, 24, is the LCM. Factors of 18: 1, 2, 3, 6, 9, 18. Factors of 24: 1, 2, 3, 4, 6, 8, 12, 24. The largest shared factor, 6, is the GCF.

A warning about three or more numbers

The rule ( text{GCF} times text{LCM} = ) product only holds for two numbers. For 2, 4 and 8: the GCF is 2 and the LCM is 8, so ( 2 times 8 = 16 ), but ( 2 times 4 times 8 = 64 ). With three or more numbers, use prime factorizations, as the calculator does.

Worked example: a scheduling problem

Two buses leave a station at 8:00. One returns every 12 minutes and the other every 18 minutes. When are they both back together? ( text{LCM}(12, 18) = 36 ), so at 8:36.

Worked example: cutting into squares

A 48 cm by 180 cm sheet is cut into equal squares, as large as possible, with nothing left over. The side of each square is ( text{GCF}(48, 180) = 12 ) cm, giving ( 4 times 15 = 60 ) squares.

gcf and LCM calculator for algebraic terms

The same rules work for monomials: ( text{GCF}(12x^3y, 18x^2y^2) = 6x^2y ) (lowest powers) and ( text{LCM} = 36x^3y^2 ) (highest powers). Factoring out the GCF is the first step in factoring any polynomial; see polynomials.

A handwritten algebraic term 'a squared' on a piece of paper.

Practice problems

  1. GCF and LCM of 36 and 60.
  2. Also, GCF and LCM of 17 and 51.
  3. GCF and LCM of 9 and 28.
  4. LCM of 4, 6 and 10.

Answers: 1. Then, GCF 12, LCM 180. 2. GCF 17, LCM 51 (51 is a multiple of 17). 3. GCF 1 (coprime), LCM 252. 4. 60.

Worked example: adding fractions

Add ( frac{5}{12} + frac{7}{18} ). The least common denominator is ( text{LCM}(12, 18) = 36 ):

$$frac{5}{12} + frac{7}{18} = frac{15}{36} + frac{14}{36} = frac{29}{36}$$

Using ( 12 times 18 = 216 ) as the denominator also works, but you then have to simplify a larger fraction.

Euclid’s algorithm on larger numbers

GCF(1071, 462): ( 1071 = 2 times 462 + 147 ), then ( 462 = 3 times 147 + 21 ), then ( 147 = 7 times 21 + 0 ). The GCF is 21, found in three steps without factoring either number. This 2,300-year-old method is still used inside computers today.

GCF and LCM at a glance

NumbersGCFLCMCheck: GCF × LCM
8, 1242496 = 8 × 12
15, 25575375 = 15 × 25
14, 21742294 = 14 × 21
9, 161144144 = 9 × 16

Coprime numbers, like 9 and 16, always have GCF 1 and LCM equal to their product.

Related guides

Further reading

FAQ

What is the difference between GCF and LCM?

The GCF is the biggest number that divides into all of them; the LCM is the smallest number they all divide into.

Is GCF the same as GCD and HCF?

Yes. Greatest common factor, greatest common divisor and highest common factor are three names for the same thing.

What is the LCM of two prime numbers?

Their product, because they share no factors. For example ( text{LCM}(5, 7) = 35 ).

What does a GCF of 1 mean?

The numbers are coprime (relatively prime): they share no factor other than 1, like 8 and 15.

Can the LCM be smaller than the numbers?

No. Similarly, the LCM is at least as large as the biggest of the numbers, and the GCF is at most the smallest.

What is the GCF of a number and 0?

The number itself, since every number divides 0. The LCM involving 0 is usually left undefined or taken as 0.

Embed this calculator on your website

Teachers, tutors and bloggers are welcome to use this calculator for free. Copy the code below and paste it into any page (in WordPress, use a "Custom HTML" block). The small script makes the calculator grow to fit its answer; if your site removes scripts, it still works at a fixed height. Please keep the credit link.

More calculators

See all calculators