LCM & GCF Calculator: Prime Table, Euclid & Venn Steps

Find the greatest common factor and the least common multiple of up to 30 numbers at once. Whole numbers of any size work, and so do decimals and fractions. The working is shown four ways: a prime factorization table, a Venn diagram, the ladder method and Euclid’s algorithm.

LCM & GCF Calculator
Separate with commas or spaces. Whole numbers of any size work, and so do decimals (0.6, 1.5) and fractions (2/3, 4/9).
GCF (greatest common factor)–
LCM (least common multiple)–
Prime factorization method GCF takes the lowest power of each shared prime, LCM the highest power of every prime
Venn diagram of prime factors
Ladder (division) method
Euclidean algorithm for the GCF
    More from these numbers

      GCF or LCM: Which One Do You Need?

      The two answers point in opposite directions. The GCF is never bigger than your smallest number, and the LCM is never smaller than your biggest one.

      Use the GCF when you want to…Use the LCM when you want to…
      split things into the largest equal groupsfind when repeating events line up again
      cut lengths into the longest equal piecesfind the smallest amount that splits evenly several ways
      simplify a fractionfind a common denominator for adding fractions

      The GCF is also called the GCD (greatest common divisor, not denominator) or the HCF (highest common factor). The LCD, or least common denominator, is the LCM of the denominators of some fractions.

      One Set of Numbers, Four Methods

      Here is how each method handles 12, 18 and 30. All four give a GCF of 6 and an LCM of 180.

      Prime factorization table. Write each number as a product of primes: 12 = 2² × 3, 18 = 2 × 3², 30 = 2 × 3 × 5. For the GCF, take each prime that appears in every number, using its lowest power: 2 × 3 = 6. For the LCM, take every prime that appears anywhere, using its highest power: 2² × 3² × 5 = 180. Mixing these up is a common mistake, and it even appears on some calculator sites. If the GCF took the highest power, it would be 2² × 3² = 36, which doesn’t divide 30.

      Ladder (division) method. Divide by a prime that goes into at least one number, and bring down any number it doesn’t divide. Keep going until every number is 1. In the calculator, the rows where the prime divides every number are highlighted. For 12, 18 and 30, those rows are 2 and 3, so the GCF is 2 × 3 = 6. The full column of divisors, 2 × 2 × 3 × 3 × 5, gives the LCM of 180.

      Venn diagram. Each circle holds one number’s prime factors, and the shared factors sit in the overlap. The centre, where all three circles meet, holds 2 and 3, so the GCF is 6. Multiply everything in the diagram for the LCM. The calculator draws it for two or three numbers.

      Euclid’s algorithm. Divide the larger number by the smaller and keep the remainder. Then divide the smaller number by that remainder, and repeat until the remainder is 0. The last non-zero remainder is the GCF. For 18 and 12: 18 = 1 × 12 + 6, then 12 = 2 × 6 + 0, so GCF(18, 12) = 6. Then GCF(6, 30) = 6.

      The first three methods depend on factoring, which gets slow for big numbers. Euclid’s algorithm never needs prime factors at all.

      Why Euclid’s Algorithm Wins for Big Numbers

      Take 9,876,543,210 and 1,234,567,890. Factoring them by hand would take a long time. Euclid’s algorithm takes two lines:

      • 9,876,543,210 = 8 × 1,234,567,890 + 90
      • 1,234,567,890 = 13,717,421 × 90 + 0

      So the GCF is 90. Some guides teach an older version of the algorithm that subtracts the smaller number over and over instead of dividing. It gives the same answer, but for these two numbers it needs 13,717,428 subtractions. Division does each run of subtractions in one step.

      The GCF × LCM Shortcut Only Works for Two Numbers

      For two numbers, GCF × LCM equals their product: 6 × 36 = 216 = 12 × 18. That gives a quick way to find the LCM: LCM(a, b) = a × b ÷ GCF(a, b).

      With three or more numbers the rule breaks. For 12, 18 and 30, GCF × LCM is 6 × 180 = 1,080, but the product is 6,480. To find the LCM of several numbers with this formula, apply it in pairs: LCM(12, 18) = 36, then LCM(36, 30) = 180.

      Decimals and Fractions

      Decimals. Multiply every number by the same power of 10 to make them whole, solve, and then divide back. Suppose you want square tiles that fit a 3.6 m by 2.4 m floor with no cutting. Multiplying by 10 gives 36 and 24, with a GCF of 12. Dividing back gives tiles 1.2 m wide, laid 3 by 2. Type 3.6, 2.4 into the calculator to check.

      Fractions. Write each fraction in lowest terms first. Then:

      • GCF = GCF of the numerators ÷ LCM of the denominators
      • LCM = LCM of the numerators ÷ GCF of the denominators

      For 2/3 and 4/9, the GCF is 2 ÷ 9 = 2/9 and the LCM is 4 ÷ 3 = 4/3. You can check both: 2/3 ÷ 2/9 = 3 and 4/9 ÷ 2/9 = 2 are whole numbers, and so are 4/3 ÷ 2/3 = 2 and 4/3 ÷ 4/9 = 3.

      Zero, Negatives and Numbers With Nothing in Common

      • Zero. Every non-zero number divides 0, so GCF(a, 0) = a. GCF(0, 0) is undefined. The only multiple of 0 is 0 itself, so no positive common multiple exists. Some calculators, including this one, report the LCM as 0 by convention, while some textbooks call it undefined.
      • Negative numbers. The calculator uses absolute values, because −12 and 12 have the same divisors. It tells you when it has done this.
      • Relatively prime numbers. When the GCF is 1, like 15 and 28, the numbers share no prime factor. For two such numbers, the LCM is simply their product: 15 × 28 = 420. Any two consecutive whole numbers, such as 20 and 21, are always relatively prime.

      Everyday Problems

      • Blinking lights. One light flashes every 6 seconds and another every 8 seconds. They flash together every LCM(6, 8) = 24 seconds.
      • Cutting ribbon. Ribbons 48 cm and 60 cm long are cut into equal pieces that are as long as possible, with nothing left over. Each piece is GCF(48, 60) = 12 cm, which makes 4 + 5 = 9 pieces.
      • Adding fractions. For 5/12 + 7/18, the least common denominator is LCM(12, 18) = 36. That gives 15/36 + 14/36 = 29/36. For other sums, use the Fraction Calculator.
      • Simplifying fractions. 84/60 divided top and bottom by GCF(84, 60) = 12 becomes 7/5 in one step.