Skip to content
ChalkCalculator

School

LCM and GCF Calculator

Find the least common multiple (LCM) and greatest common factor (GCF) of two or more whole numbers, with each prime factorization worked out.

Enter two or more whole numbers to find their LCM and GCF.

Two to ten whole numbers, separated by commas or spaces. Leave out thousands separators: 1200, not 1,200.

Exact calculation. Given your inputs, this is the answer — no estimation involved.

How this calculator works

Every whole number above 1 breaks into prime numbers in exactly one way: 12 = 2 × 2 × 3, written 2² × 3. Once each number is broken down, both answers can be read straight off the primes.

The greatest common factor is the largest number that divides all of them. Take only the primes that every number shares, each at the lowest power it appears with. The least common multiple is the smallest number all of them divide into. Take every prime that appears anywhere, each at its highest power.

Enter two to ten numbers. The calculator shows each factorization and the product that gives each answer. For two numbers it also checks that GCF × LCM equals the two numbers multiplied together, which is always true for a pair.

The greatest common factor goes by other names: the greatest common divisor (GCD) and, outside the US, the highest common factor (HCF). They are the same number.

The formula

Exactly what happens to your numbers, step by step.

  1. Greatest common factor

    GCF = product of the shared primes,
          each at its lowest power
  2. Least common multiple

    LCM = product of all the primes,
          each at its highest power
  3. For two numbers

    GCF(a, b) × LCM(a, b) = a × b

A worked example

Hot dogs come in packs of 10 and buns in packs of 8. What is the fewest of each you can buy to have exactly one bun per hot dog?

What you enter

Whole numbers
10, 8

Step by step

Prime factors
10 = 2 × 5; 8 = 2³
LCM
2³ × 5 = 40
GCF
2
Packs
40 ÷ 10 = 4 packs of hot dogs; 40 ÷ 8 = 5 packs of buns

40 hot dogs and 40 buns: 4 packs and 5 packs

The LCM answers "when do the two line up?" questions: packs that match, schedules that coincide, gears that return to the start. The GCF answers "what is the biggest equal group?" questions, such as cutting two lengths of wood into the longest equal pieces.

LCM and GCF questions, worked out

Prime factorization, applied to the questions students are asked most.

  1. 1.What is the LCM of 4 and 6?

    1. Break each number into primes: 4 = 2²; 6 = 2 × 3.
    2. LCM: take every prime that appears, each at its highest power: 2² × 3 = 12.

    12.

  2. 2.What is the GCF of 24 and 36?

    1. Break each number into primes: 24 = 2³ × 3; 36 = 2² × 3².
    2. GCF: take the primes that every number shares, each at its lowest power: 2² × 3 = 12.

    12.

  3. 3.What is the LCM of 8, 12 and 20?

    1. Break each number into primes: 8 = 2³; 12 = 2² × 3; 20 = 2² × 5.
    2. LCM: take every prime that appears, each at its highest power: 2³ × 3 × 5 = 120.

    120.

  4. 4.What is the greatest common factor of 48 and 180?

    1. Break each number into primes: 48 = 2⁴ × 3; 180 = 2² × 3² × 5.
    2. GCF: take the primes that every number shares, each at its lowest power: 2² × 3 = 12.

    12.

  5. 5.What is the least common denominator of 5/12 and 7/18?

    1. The least common denominator is the LCM of the denominators, 12 and 18.
    2. Break each number into primes: 12 = 2² × 3; 18 = 2 × 3².
    3. LCM: take every prime that appears, each at its highest power: 2² × 3² = 36.

    36: 5/12 = 15/36 and 7/18 = 14/36.

Assumptions

Every result here rests on these. Change your inputs and the result changes with them.

  • Whole numbers from 1 to one trillion, two to ten at a time.
  • Zero and negative numbers are not accepted. Every number divides 0, so it has no useful common multiple, and school LCM and GCF questions use positive whole numbers.

What this cannot tell you

  • Thousands separators are not allowed, because a comma also separates numbers: write 1200, not 1,200.
  • It does not find the LCM or GCF of fractions or of algebraic expressions.

Questions people ask

How do you find the LCM of two numbers?

Break both into primes and take every prime at its highest power. For 4 = 2² and 6 = 2 × 3, that is 2² × 3 = 12. For small numbers you can also list multiples until they match: 4, 8, 12 and 6, 12. The first one in both lists, 12, is the LCM.

How do you find the GCF?

Break each number into primes and multiply the primes they all share, each at its lowest power. For 24 = 2³ × 3 and 36 = 2² × 3², the shared primes are 2² and 3, so the GCF is 12.

What is the difference between the LCM and the GCF?

The GCF is the biggest number that goes into all of them, so it is never larger than the smallest number. The LCM is the smallest number they all go into, so it is never smaller than the largest. For 12 and 18 the GCF is 6 and the LCM is 36.

How is the LCM used with fractions?

The least common denominator of two fractions is the LCM of their denominators. To add 5/12 and 7/18, the LCM of 12 and 18 is 36, so rewrite them as 15/36 and 14/36 and add to get 29/36. The fraction calculator does this for you.

Is GCF the same as GCD and HCF?

Yes. Greatest common factor, greatest common divisor and highest common factor are three names for the same number. GCF is most common in US schools, GCD in higher math and programming, and HCF in the UK and India.

Sources and review

Cite this calculator

For coursework, a resource list or your own site. How every calculator is built and checked is set out on the methodology page.

Citation

Chalk Calculator. (2026, October 12). LCM and GCF Calculator (Methodology version 1.0.0). https://chalkcalculator.com/lcm-calculator/

Link to it from your site

<a href="https://chalkcalculator.com/lcm-calculator/">LCM and GCF Calculator</a> from Chalk Calculator