Free tool

GCF and LCM calculator, with the steps.

Type two to ten whole numbers to get their greatest common factor (also called GCD or HCF) and their least common multiple, both at once. Pick how you want to see the working: prime factorisation, the Euclidean algorithm, listing factors and multiples, or the ladder method taught in many classrooms. Numbers can be very large, and with two numbers the page also puts a fraction into its lowest terms.

Show the working

Separate numbers with spaces, commas or new lines. Whole numbers only. A minus sign is ignored.

Worked out in your browser. Nothing is sent anywhere.

The maths

One shares, one meets.

01 / GCF

The biggest shared factor

The largest whole number that divides every number in the list with nothing left over.

02 / LCM

The first shared multiple

The smallest number that every number in the list divides into with nothing left over.

03 / Link

Two numbers, one rule

For two numbers, GCF × LCM = the first number × the second number.

Guide

How to find the GCF and LCM, with worked examples.

A GCF calculator finds the greatest common factor of a set of numbers: the biggest whole number that divides all of them exactly. An LCM calculator finds the least common multiple: the smallest number that all of them divide into exactly. This page works out both for up to ten numbers at once and shows the working four ways, so you can match the method your class or textbook uses. Big numbers are fine, because the page uses exact whole-number arithmetic with no rounding.

How to use the GCF and LCM calculator

  1. Type your whole numbers in Numbers (2 to 10), separated by spaces, commas or new lines.
  2. Read the two big cards: Greatest common factor (GCF) and Least common multiple (LCM).
  3. Choose how to see the working under Show the working: Prime factors, Euclidean algorithm, Listing or Ladder (cake).
  4. With two numbers, the card under the answers also shows the fraction in lowest terms.
  5. Use Copy result to copy the answers, or Copy link to share your numbers.

Method 1: prime factorisation

Split each number into primes. 12 = 2² × 3 and 18 = 2 × 3². For the GCF, keep the primes both numbers share, each to its lowest power: 2 and 3, so 2 × 3 = 6. For the LCM, keep every prime that appears, each to its highest power: 2² and 3², so 4 × 9 = 36. The page lays the primes out in a table with the lowest and the highest power of each, so you can see where the answers come from.

Method 2: the Euclidean algorithm

This method needs no factoring, so it works for huge numbers. Divide the bigger number by the smaller and keep the remainder. Repeat with the smaller number and the remainder until the remainder is 0. The last non-zero remainder is the GCF. For 48 and 18: 48 = 2 × 18 + 12, then 18 = 1 × 12 + 6, then 12 = 2 × 6 + 0. The GCF is 6. For two numbers, LCM = a × b ÷ GCF, so the LCM of 48 and 18 is 48 × 18 ÷ 6 = 144. For more numbers the page works through them one at a time.

Method 3: listing

List all the factors of each number and pick the biggest one in every list. The factors of 12 are 1, 2, 3, 4, 6 and 12. The factors of 18 are 1, 2, 3, 6, 9 and 18. The shared ones are 1, 2, 3 and 6, so the GCF is 6. For the LCM, list multiples instead. Multiples of 4 are 4, 8, 12 and multiples of 6 are 6, 12, so the LCM of 4 and 6 is 12. Listing is easy to follow but gets long, so the page only does it for numbers up to 1,000,000.

Method 4: the ladder or cake method

Write the numbers in a row. Find a prime that divides at least two of them, write it on the left, and divide. Numbers the prime does not divide are brought down. Keep going until no prime divides two numbers in the bottom row. For 12, 18 and 30: divide by 2 to get 6, 9, 15, then by 3 to get 2, 3, 5. No prime divides two of those. The GCF is the product of the primes that divided every number: 2 × 3 = 6. The LCM is all the primes on the left times the bottom row: 2 × 3 × 2 × 3 × 5 = 180.

What the GCF and LCM are used for

TaskUseExample
Simplify a fractionGCF18/24: the GCF is 6, so it is 3/4
Add fractions with different bottomsLCM1/12 + 1/18: the LCM is 36, so 3/36 + 2/36 = 5/36
Split into equal groupsGCF24 and 36 items fit into 12 equal groups
Find when two cycles meetLCMBuses every 12 and 18 minutes meet again after 36 minutes

Special cases

  • If the GCF is 1, the numbers are coprime (also called relatively prime). Then the LCM of two numbers is just their product.
  • The GCF of a number and 0 is that number, so GCF(0, 5) = 5. The LCM of any list containing 0 is 0. A list of only zeros has no GCF.
  • Negative numbers use their absolute value, and the page says so.
  • Very large numbers cannot always be split into primes in the time the page allows. The Euclidean algorithm still works, and the page says when a method cannot finish.

For the factors and prime factorisation of one number, use the factor calculator. To simplify and add fractions with the working shown, use the fraction calculator, and for the remainder of a division, the remainder calculator.

Questions

Good to know.

What is the difference between GCF, GCD and HCF?

Nothing. They are three names for the same number: the greatest common factor, greatest common divisor and highest common factor.

How do you find the GCF of three or more numbers?

Find the GCF of the first two, then the GCF of that answer and the next number, and so on. The calculator does this for up to ten numbers.

How do you find the LCM of two numbers?

Divide their product by their GCF. For 12 and 18, 12 × 18 = 216, and 216 ÷ 6 = 36.

What is the GCF of two prime numbers?

It is 1, because two different primes share no factor but 1. Their LCM is their product.

How do I simplify a fraction with the GCF?

Divide the top and the bottom by their GCF. 18/24 has a GCF of 6, so it becomes 3/4. Type the two numbers and read the lowest terms card.

Can the GCF be bigger than the numbers?

No. The GCF can be as big as the smallest number but never bigger. The LCM is at least as big as the largest number.

Does it work for decimals?

No, only whole numbers. For a decimal, scale it to a whole number first, for example by working with 25 and 150 instead of 0.25 and 1.5.

How big can the numbers be?

Up to 150 digits each. The page uses exact whole-number arithmetic, so there is no rounding at any size.

Is anything sent anywhere?

No. Everything is worked out in your browser.