GCF & LCM Calculator (Free Step-by-Step Tool)

Fractions & numbersFreeNo sign-up

A GCF and LCM calculator finds the greatest common factor and the least common multiple of whole numbers. For 24 and 36, write each number as primes: 24 = 2³ × 3 and 36 = 2² × 3². The GCF uses the lowest powers, 2² × 3 = 12. The LCM uses the highest powers, 2³ × 3² = 72. Check: 12 × 72 = 864 = 24 × 36.

GCF and LCM calculator
Separate the numbers with commas or spaces, for example 12, 18, 30. Very large numbers (up to 30 digits) work too.
Try:
Answer
Greatest common factor
12

GCF(24, 36)

Least common multiple
72

LCM(24, 36)

The GCF of 24 and 36 is 12, the largest number that divides both. The LCM is 72, the smallest number both divide into.

24 in primes2³ × 3
36 in primes2² × 3²
Coprime?No (GCF = 12)
Fraction 24/36 simplified2/3
Least common denominator of 1/24 and 1/3672
Check: GCF × LCM = the product of the two numbers12 × 72 = 864 and 24 × 36 = 864 ✓ equal
Show steps: 4 methods
242122623
362182933
24 = 2 × 2 × 2 × 3 = 2³ × 3
36 = 2 × 2 × 3 × 3 = 2² × 3²
  1. Break each number into primes. Divide by the smallest prime that goes in, then repeat with the quotient until only primes are left. The circled numbers at the ends of the branches in each factor tree are the prime factors.
  2. GCF: take only the primes that appear in every number, each with its lowest power: 2² × 3 = 12.
  3. LCM: take every prime that appears in any number, each with its highest power: 2³ × 3² = 72.
2436232²3
Venn diagram: shared prime factors go in the overlap. The GCF is the product of the overlap; the LCM is the product of every prime factor in the diagram, each counted once.
Prime 24 36 GCF: lowest LCM: highest
2 2³ 2² 2² 2³
3 3 3² 3 3²
Product 24 36 12 72

GCF & LCM Calculator (Free Step-by-Step Tool)
Embed this calculator on your site

Free to use on class pages, blogs and course pages. Copy the code below and paste it into your page:

How to use the GCF and LCM calculator

  1. Type 2 to 10 whole numbers in the box, separated by commas or spaces (for example 12, 18, 30). The answer updates as you type.
  2. Read the GCF and LCM at the top, then each number’s prime factors and, for two numbers, the GCF × LCM check.
  3. Open Show steps and switch between the four methods: prime factors (with factor trees, a Venn diagram and an exponent table), listing factors and multiples, the Euclidean algorithm, and the ladder (cake) method.
  4. For story problems, use the Word problems tab: equal groups and square tiles (GCF) or “together again” schedules (LCM).

GCF vs. LCM: what each one means

The greatest common factor (GCF) is the largest number that divides every number in the list with no remainder. It is also called the greatest common divisor (GCD) or highest common factor (HCF).

The least common multiple (LCM) is the smallest positive number that every number in the list divides into. The least common denominator of two fractions is the LCM of their denominators.

GCF LCM
Question it answers Largest number that goes into all of them Smallest number all of them go into
Size At most the smallest number At least the largest number
Prime factors Shared primes, lowest powers All primes, highest powers
Example: 12 and 18 6 36
Typical use Simplifying fractions, equal groups Common denominators, repeating schedules

Four ways to find the GCF and LCM

1. Listing factors and multiples

List every factor of each number and pick the largest one they share. Then list multiples until one shows up in every list. For 12 and 18: the factors of 12 are 1, 2, 3, 4, 6, 12 and the factors of 18 are 1, 2, 3, 6, 9, 18, so the GCF is 6. The multiples of 12 are 12, 24, 36 and the multiples of 18 are 18, 36, so the LCM is 36. It is clear for small numbers but slow for big ones.

2. Prime factorization (factor trees and Venn diagram)

Break each number into primes with a factor tree. GCF = the primes every number shares, each with its lowest power. LCM = every prime that appears, each with its highest power. In a Venn diagram, shared primes go in the overlap: the GCF is the product of the overlap and the LCM is the product of everything in the diagram.

3. The Euclidean algorithm

Divide the larger number by the smaller one, then divide the old divisor by the remainder, until the remainder is 0. The last nonzero remainder is the GCF. It needs no factoring, so it is fastest for large numbers. Then LCM(a, b) = a × b ÷ GCF(a, b).

4. The ladder (cake) method

Write the numbers in a row and divide them all by a prime that goes into every one, writing the quotients underneath. When no prime divides all of them, the GCF is the product of the divisors on the left. For the LCM, keep dividing by any prime that goes into at least two numbers (bring the others down), then multiply the left column by the bottom row.

Worked examples

Example 1: GCF and LCM of 12, 18 and 30

12 = 2² × 3, 18 = 2 × 3², 30 = 2 × 3 × 5. The primes in all three are 2 and 3, each at least to the first power, so the GCF is 2 × 3 = 6. For the LCM, take 2², 3² and 5: 4 × 9 × 5 = 180. Note that 6 × 180 = 1,080 is not 12 × 18 × 30 = 6,480: the product rule only works for two numbers.

Example 2: Euclidean algorithm for 1071 and 462

1071 = 2 × 462 + 147. Then 462 = 3 × 147 + 21. Then 147 = 7 × 21 + 0. The remainder is 0, so the GCF is 21. The LCM is 1071 × 462 ÷ 21 = 23,562.

Example 3: the ladder for 48, 180, 300 and 420

Divide all four by 2 (24, 90, 150, 210), by 2 again (12, 45, 75, 105) and by 3 (4, 15, 25, 35). No prime divides all four now, so the GCF is 2 × 2 × 3 = 12. Next, 5 divides 15, 25 and 35 but not 4, so 4 comes down unchanged: 4, 3, 5, 7. The LCM is 2 × 2 × 3 × 5 × 4 × 3 × 5 × 7 = 25,200.

The GCF × LCM shortcut for two numbers

For any two positive whole numbers, GCF(a, b) × LCM(a, b) = a × b. So once you know the GCF, LCM = a × b ÷ GCF. For 24 and 36: 24 × 36 = 864, and 864 ÷ 12 = 72. It works because the GCF takes the lower power of each prime and the LCM the higher one, so together they use every prime factor exactly once. It does not hold for three or more numbers.

GCF or LCM? Telling word problems apart

  • Use the GCF when you split things into the largest possible equal groups, cut pieces as long as possible, or pick the largest square tile. Example: 18 red roses, 27 white roses and 45 tulips make at most 9 identical bouquets, each with 2 red roses, 3 white roses and 5 tulips.
  • Use the LCM when things repeat on different cycles and you want the next time they line up. Example: if Bus A leaves every 12 minutes and Bus B every 18 minutes, they leave together again after 36 minutes, after 3 trips of Bus A and 2 of Bus B.

A quick test: if the answer must be smaller than the numbers you start with, it is a GCF problem. If it must be larger, it is an LCM problem. A 60 by 84 inch wall, for example, can be covered with 12 inch square tiles, 5 × 7 = 35 of them, because GCF(60, 84) = 12.

GCF and LCM quick reference table

Numbers GCF LCM
6 and 8 2 24
7 and 9 1 63
8 and 12 4 24
9 and 12 3 36
10 and 15 5 30
12 and 18 6 36
14 and 21 7 42
15 and 20 5 60
16 and 24 8 48
18 and 24 6 72
20 and 30 10 60
24 and 36 12 72

Common mistakes to avoid

  • Mixing up the powers. The GCF takes the lowest power of each shared prime and the LCM takes the highest. Swapping them gives 2³ × 3² = 72 as the “GCF” of 24 and 36.
  • Leaving out a prime in the LCM. Every prime that appears in any number belongs in the LCM, even if only one number has it (the 5 in 12, 18, 30).
  • Multiplying the numbers to get the LCM. 12 × 18 = 216 is a common multiple, but the least one is 36. Multiplying only gives the LCM when the GCF is 1.
  • Using the product rule for three numbers. GCF × LCM = a × b is a two-number rule only.

Using the calculator for homework

Work the problem by hand first, then type the same numbers in and compare. If your answer differs, open the steps for the method your teacher uses and find the first line that does not match yours. A quick accuracy check: the GCF must divide the smallest number, and the LCM must be a multiple of the largest.

GCF and LCM practice quiz: 10 questions

Test yourself with 10 multiple-choice questions. Choose an answer and press Submit to see if you are right and why. Your score appears at the end.

Question 1 of 10
1. What is the GCF of 16 and 40?

Found a mistake? Let us know!

2. What is the LCM of 6 and 10?

Found a mistake? Let us know!

3. What is the GCF of 18, 24 and 42?

Found a mistake? Let us know!

4. What is the LCM of 4, 6 and 9?

Found a mistake? Let us know!

5. The GCF of two numbers is 6 and their product is 432. What is their LCM?

Found a mistake? Let us know!

6. Using the Euclidean algorithm on 252 and 105, what is the last nonzero remainder?

Found a mistake? Let us know!

7. Which pair of numbers is coprime (GCF = 1)?

Found a mistake? Let us know!

8. A teacher has 32 markers and 48 crayons and wants identical kits with nothing left over. What is the largest number of kits?

Found a mistake? Let us know!

9. One light blinks every 8 seconds and another every 12 seconds. They blink together now. After how many seconds do they next blink together?

Found a mistake? Let us know!

10. In prime factor form, a = 2³ × 5 and b = 2 × 3 × 5². What is GCF(a, b)?

Found a mistake? Let us know!

Frequently asked questions

How do you find the GCF using prime factorization?

Write each number as a product of primes, circle the primes that appear in every number, and multiply them using the lowest power of each. For 24 = 2³ × 3 and 36 = 2² × 3², the shared primes are 2² and 3, so the GCF is 4 × 3 = 12.

How do you find the LCM?

Take every prime that appears in any of the numbers, use its highest power, and multiply. For two numbers you can also divide their product by the GCF: LCM(24, 36) = 864 ÷ 12 = 72.

Can the calculator handle more than two numbers?

Yes. It takes 2 to 10 whole numbers, each up to 30 digits long. For numbers above 1,000,000,000,000 it skips factoring and uses the Euclidean algorithm, which works at any size.

What is the GCF of two prime numbers?

Two different primes share no factor except 1, so their GCF is 1 and their LCM is their product. For 7 and 11 the LCM is 77. Numbers with a GCF of 1, such as 8 and 9, are called relatively prime or coprime, even when neither is prime.

What is the GCF of 0 and a number?

Every whole number divides 0, so GCF(0, n) = n. For example, GCF(0, 15) = 15. The LCM of 0 and any number is taken as 0, and GCF(0, 0) is not defined.

Related calculators

More fractions & numbers calculators

Browse all 206 calculators

Related to This Article

What people say about "GCF Calculator (and LCM): Step-by-Step, 4 Methods"?

No one replied yet.

Leave a Reply