Skip to content

GCF & LCM Calculator

Calculate Greatest Common Factor and Least Common Multiple using prime factorization

Calculator Details

Greatest Common Factor (GCF):6See results ↓

1 to 10 positive whole numbers up to 1,000,000, separated by commas or spaces

Your Results

Greatest Common Factor (GCF): 6

Greatest Common Factor (GCF)

6

Prime factorization: 2 × 3

Results

GCF (Greatest Common Factor)

6

2 × 3

LCM (Least Common Multiple)

36

2^2 × 3^2

Numbers Count

2

12, 18

Compare scenarios

Save these inputs as a scenario, change them, and compare the results side by side.

Loading, available in a moment

Detailed Breakdown

Prime factorization of each number
NumberPrime factorizationPrime factors
122^2 × 32 × 2 × 3
182 × 3^22 × 3 × 3
GCF = 62 × 3Lowest power of each common prime
LCM = 362^2 × 3^2Highest power of every prime

How This Calculator Works

How GCF & LCM Work

This calculator uses prime factorization to find the Greatest Common Factor (GCF) and Least Common Multiple (LCM) of two or more numbers. Prime factorization breaks each number into its prime building blocks.

Your numbers

12 = 2^2 × 3
18 = 2 × 3^2
GCF (lowest power of each common prime) = 2 × 3 = 6
LCM (highest power of every prime) = 2^2 × 3^2 = 36

Prime Factorization Method

Step 1: Find prime factors of each number
12 = 2² × 3 (factors: 2, 2, 3)
18 = 2 × 3² (factors: 2, 3, 3)

Step 2: For GCF, take minimum exponent of common primes
GCF = 2¹ × 3¹ = 6

Step 3: For LCM, take maximum exponent of all primes
LCM = 2² × 3² = 36

What is GCF (Greatest Common Factor)?

The GCF is the largest number that divides evenly into all given numbers. It represents the product of common prime factors with their minimum exponents. For example, the GCF of 12 and 18 is 6, because 6 is the largest number that divides both 12 and 18 without a remainder.

What is LCM (Least Common Multiple)?

The LCM is the smallest number that is a multiple of all given numbers. It represents the product of all prime factors with their maximum exponents. For example, the LCM of 12 and 18 is 36, because 36 is the smallest number that both 12 and 18 divide into evenly.

GCF × LCM Property (Two Numbers Only)

For two numbers a and b:
GCF(a, b) × LCM(a, b) = a × b

Example: GCF(12, 18) × LCM(12, 18) = 12 × 18
6 × 36 = 216 ✓

Frequently Asked Questions

What is the difference between GCF and LCM?

GCF (Greatest Common Factor) is the largest number that divides evenly into all given numbers, while LCM (Least Common Multiple) is the smallest number that all given numbers divide into evenly. GCF finds what the numbers have in common; LCM finds the smallest number they all share as a multiple.

Why use prime factorization instead of other methods?

Prime factorization is the most reliable method for finding GCF and LCM, especially for multiple numbers or large numbers. It clearly shows how the answer is derived and works consistently for any set of positive integers. Other methods like listing multiples become impractical for large numbers.

What does it mean when GCF is 1?

When the GCF is 1, the numbers are called "relatively prime" or "coprime." This means they share no common prime factors and have no common divisors other than 1. For example, 7 and 13 are coprime because both are prime numbers with GCF = 1.

How is GCF useful in simplifying fractions?

The GCF is essential for simplifying fractions to their lowest terms. To simplify a fraction, divide both the numerator and denominator by their GCF. For example, to simplify 12/18, find GCF(12, 18) = 6, then divide: 12÷6 / 18÷6 = 2/3.

How is LCM useful in adding fractions?

The LCM is used to find the least common denominator (LCD) when adding or subtracting fractions with different denominators. For example, to add 1/12 + 1/18, find LCM(12, 18) = 36, convert to 3/36 + 2/36 = 5/36.

Does the GCF × LCM = a × b formula work for three or more numbers?

No, the property GCF × LCM = a × b only applies to exactly two numbers. For three or more numbers, there is no simple multiplicative relationship between GCF and LCM. You must calculate each independently using prime factorization.

What if one number is a multiple of another?

When one number is a multiple of another (e.g., 50 and 100), the smaller number is the GCF and the larger number is the LCM. This is because the smaller number divides the larger one exactly, so GCF(50, 100) = 50 and LCM(50, 100) = 100.

Can GCF and LCM be calculated for negative numbers or decimals?

This calculator accepts positive whole numbers only. For negative numbers, the usual convention is to use their absolute values (GCF(-12, 18) = 6). GCF and LCM are normally defined for integers only, so decimals have no standard GCF; scale them to whole numbers first if your problem calls for it.

What are practical applications of GCF and LCM?

GCF is used in simplifying fractions, dividing items into equal groups, and finding patterns in number theory. LCM is used in scheduling (finding when events coincide), adding fractions (finding common denominators), and solving problems about repeated cycles (e.g., traffic lights, gear ratios).

GCF and LCM of 1 to 10 positive whole numbers up to 1,000,000, by prime factorization, with the LCM worked out exactly however large it gets. Not included: zero, negative numbers, decimals and polynomials.

GCF and LCM Calculator: Prime Factorization and Euclid's Method

By FindMySum · Last reviewed

A GCF and LCM calculator finds two numbers that sit on either side of any set of whole numbers. The greatest common factor (GCF) is the largest number that divides every number in the set exactly. The least common multiple (LCM) is the smallest positive number that every number in the set divides into exactly. You need the GCF to simplify a fraction or split things into equal groups, and the LCM to find a common denominator or to work out when repeating cycles line up. This calculator takes up to ten positive whole numbers, up to 1,000,000 each, and shows the prime factorization behind both answers.

Prime factorization: the method the calculator uses

Every whole number greater than 1 can be written as a product of prime numbers in exactly one way, apart from the order of the factors. This is the fundamental theorem of arithmetic, and it is what makes the method work. Once each number is broken into primes, the GCF and LCM can be read off directly:

  • GCF: take each prime that appears in every number, raised to the lowest power it has in any of them.
  • LCM: take every prime that appears in any number, raised to the highest power it has in any of them.

The reasoning is short. A common factor can't contain more copies of a prime than the number with the fewest copies, so the lowest power is as far as the GCF can go. A common multiple must contain at least as many copies as the number with the most, so the highest power is the least the LCM can get away with.

The calculator factors each number by trial division: it divides out 2 as many times as possible, then 3, 5, 7 and the other odd numbers up to the square root of what remains. Whatever is left at the end, if greater than 1, is itself prime.

Worked example: the calculator's defaults

The calculator opens with the numbers 12 and 18.

  1. Factor each number: 12 = 2 × 2 × 3 = 2² × 3, and 18 = 2 × 3 × 3 = 2 × 3².
  2. The primes involved are 2 and 3.
  3. GCF, lowest powers: 2 appears as 2² and 2¹, so take 2¹; 3 appears as 3¹ and 3², so take 3¹. GCF = 2 × 3 = 6.
  4. LCM, highest powers: take 2² and 3². LCM = 4 × 9 = 36.

A useful check for two numbers: the GCF times the LCM equals the product of the numbers. Here 6 × 36 = 216, and 12 × 18 = 216.

Three numbers

Enter 24, 36 and 60 and the calculator gives:

NumberPrime factorization
242³ × 3
362² × 3²
602² × 3 × 5
GCF2² × 3 = 12
LCM2³ × 3² × 5 = 360

The prime 5 appears only in 60, so it is left out of the GCF (its lowest power across the three numbers is zero) but included in the LCM. The product check doesn't apply with three numbers: 12 × 360 is 4,320, while 24 × 36 × 60 is 51,840.

Euclid's algorithm: the shortcut for two numbers

Prime factorization shows its working clearly, but for large numbers there is a faster way to find a GCF that needs no factoring at all. Euclid described it around 300 BCE, and it is still the method most software uses:

  1. Divide the larger number by the smaller and keep the remainder.
  2. Replace the larger number with the smaller, and the smaller with the remainder.
  3. Repeat until the remainder is 0. The last non-zero remainder is the GCF.

For 18 and 12: 18 ÷ 12 leaves 6, then 12 ÷ 6 leaves 0, so the GCF is 6. Then the LCM follows from the product rule: 12 × 18 ÷ 6 = 36. Both methods always agree; the calculator uses prime factors because they let you see why the answer is what it is.

Where you'll use them

  • Simplifying fractions. Divide the top and bottom by their GCF: 12/18 becomes 2/3. The fraction calculator does this automatically for every result.
  • Common denominators. The LCM of the denominators is the least common denominator, which keeps the numbers small when adding fractions by hand.
  • Equal groups. With 24 apples and 36 oranges, the largest number of identical gift bags with nothing left over is the GCF, 12, each with 2 apples and 3 oranges.
  • Tiles and grids. The largest square tile that fits a 120 cm by 180 cm area exactly has a side equal to the GCF of 120 and 180.
  • Cycles. Schedules, gear teeth and repeating patterns line up again after the LCM of their periods.

Limits

The calculator works with positive whole numbers only. GCF and LCM are defined for integers, so a decimal problem needs scaling first (multiply 1.2 and 1.8 by 10 to get 12 and 18). Each number can be up to 1,000,000 and you can enter up to ten of them. A number with a large prime factor is still quick to factor at that size. To check whether a single number is prime, use the prime number calculator.

More questions

Are GCF, GCD and HCF the same thing?

Yes. Greatest common factor (GCF), greatest common divisor (GCD) and highest common factor (HCF) are three names for the same number. GCF is common in North American schools, HCF in British and Indian textbooks, and GCD in higher mathematics and programming. Least common multiple (LCM) is sometimes written lowest common multiple, with the same meaning.

How do I list all the common factors, not just the greatest?

Every common factor of a set of numbers divides their GCF, and every factor of the GCF is a common factor. So find the GCF and list its factors. For 12 and 18 the GCF is 6, and its factors 1, 2, 3 and 6 are exactly the common factors of 12 and 18.

What is the GCF and LCM of a single number?

Both are the number itself. The largest number that divides 42 is 42, and the smallest positive multiple of 42 is 42. The calculator accepts a single number and returns it as both results, along with its prime factorization, which makes it a quick way to factor a number.

Why can the LCM become so large?

When numbers share few or no prime factors, the LCM has to include all of each one's primes, so it approaches their product. Ten large numbers with no common factors can have an LCM with dozens of digits. The calculator works out the LCM with exact whole-number arithmetic and shows every digit, even beyond the 9,007,199,254,740,991 limit where ordinary computer numbers start rounding.

How do I use the LCM to work out when repeating events line up?

Find the LCM of the intervals. If one bus leaves every 12 minutes and another every 18 minutes, and both leave together at 8:00, they next leave together after LCM(12, 18) = 36 minutes, at 8:36. The same idea gives the length of a repeating rota, or when two gears return to their starting position.

Does the order in which I enter the numbers matter?

No. The GCF and LCM depend only on which numbers are in the set, not on their order, so 18, 12 gives the same results as 12, 18. You can also combine numbers in steps: the GCF of three numbers is the GCF of the first two, combined with the third, and the LCM works the same way.

Sources

This article explains how the calculator works and is general information, not financial, tax, legal or medical advice. Rules change; check the sources above or a qualified professional before you act.

Spotted a wrong result or a bug? Report a problem

May we count your visits with Invoker Analytics? It keeps a random visitor number in your browser. Your calculator inputs are never sent. Privacy policy