Free calculator

GCF and LCM Calculator

Enter two or more whole numbers to get their greatest common factor, their least common multiple and the prime factors of each number.

Report a problem or suggest a fix for this tool

What is gcf and lcm calculator?

The greatest common factor, or GCF, is the largest whole number that divides every number in a list without a remainder. It is also called the greatest common divisor or highest common factor. The least common multiple, or LCM, is the smallest number that every number in the list divides into evenly.

These two values are the basis of fraction work. The GCF reduces a fraction to its simplest form, and the LCM gives the common denominator needed to add fractions with different bottoms.

How to use the gcf and lcm calculator

  1. Type or paste two or more positive whole numbers.
  2. Separate them with commas, spaces or new lines.
  3. Read the GCF, the LCM and the prime factorization of every number.

How the gcf and lcm calculator works

The calculator finds the GCF with the Euclidean algorithm, which repeatedly replaces the larger number with the remainder of dividing it by the smaller one until the remainder is zero. The LCM of two numbers equals their product divided by their GCF, and it is extended to longer lists one number at a time.

It also factors each number into primes by trial division, so you can check the answer by hand. Exponents are shown as powers.

Worked example

For 12, 18 and 30: 12 is 2 squared times 3, 18 is 2 times 3 squared, and 30 is 2 times 3 times 5. The GCF takes the lowest power of each shared prime and gives 6. The LCM takes the highest power of every prime and gives 2 squared times 3 squared times 5, which is 180.

Common uses of the gcf and lcm calculator

  • Simplifying a fraction such as 18 over 30 to 3 over 5.
  • Finding a common denominator to add fractions.
  • Solving school math and number theory problems.
  • Scheduling events that repeat on different cycles.
  • Splitting items into equal groups with nothing left over.

Tips and common mistakes

The GCF of numbers that share no prime factor is 1. They are called coprime.

The LCM can grow very large for many numbers, so check that you really need all of them.

Background: what to know before you rely on it

The Euclidean algorithm is one of the oldest algorithms still in use, described by Euclid over two thousand years ago. It is fast because each step shrinks the numbers quickly, which is why even very large numbers can be handled in a fraction of a second.

A handy link between the two values for any pair of numbers is that GCF times LCM equals the product of the two numbers. That identity only holds for pairs, not for three or more numbers at once.

Private, free and fast

This tool runs entirely in your browser. What you type or choose is not uploaded to a server and is not saved after you close the page, which keeps it fast and private. It is free to use as often as you like. See more in all calculators, or browse the full list of tools.

Field by field guide

  • Numbers (separate with commas, spaces or new lines): Two to twenty positive whole numbers. The example is 12, 18, 30.

Change one field at a time to see how the result responds, and use the worked example above to check that you get the same answer.

Prime factor method

To find the GCF by hand, write each number as a product of primes and multiply the primes they share, using the lowest power. For the LCM, multiply every prime that appears, using the highest power.

The factorization line in the results lets you check each step.

Expert tips

  • Use the GCF to reduce fractions in one step.
  • Use the LCM to find the first time two cycles line up.
  • For a pair, check that GCF times LCM equals the product.
  • Negative numbers and zero are not accepted here.
  • Large numbers up to one trillion are factored in full.

Frequently asked questions

What is the difference between GCF and LCM?

The GCF is the largest number that divides all of your numbers. The LCM is the smallest number that all of your numbers divide into.

Is GCF the same as GCD or HCF?

Yes. Greatest common factor, greatest common divisor and highest common factor mean the same thing.

Can I enter more than two numbers?

Yes. You can enter up to twenty numbers and the tool finds the GCF and LCM of the whole list.

What if the numbers have no common factor?

Then the GCF is 1 and the numbers are coprime.

Related tools

Results are for information and education. For legal, financial, medical or security decisions, check with a qualified professional.