Skip to content

GCF and LCM Calculator

Enter two to ten whole numbers to get their greatest common factor (GCF) and least common multiple (LCM), the prime factorization of each number, and the working by both the prime-factor method and Euclid’s algorithm. The fraction calculator uses these ideas to simplify and add fractions; this page shows them on their own.

2 to 10 positive whole numbers up to 1,000,000,000,000, separated by commas, spaces or new lines. No thousands separators.

Result

Greatest common factor of 12, 18, 30

6

Least common multiple (LCM)
180
Relatively prime (GCF of 1)
No
Numbers
3
Working: prime factors
  1. Prime factors of 1212 = 2² × 3
  2. Prime factors of 1818 = 2 × 3²
  3. Prime factors of 3030 = 2 × 3 × 5
  4. GCF: primes every number shares, each to its lowest power2 × 3 = 6
  5. LCM: every prime that appears, each to its highest power2² × 3² × 5 = 180
Working: Euclid’s algorithm
  1. Divide 18 by 1218 ÷ 12 = 1 remainder 6
  2. Divide 12 by 612 ÷ 6 = 2 remainder 0
  3. GCF(18, 12)last non-zero remainder = 6
  4. Divide 30 by 630 ÷ 6 = 5 remainder 0
  5. GCF(30, 6)last non-zero remainder = 6
  6. LCM(12, 18) = product ÷ GCF12 × 18 ÷ 6 = 36
  7. LCM(36, 30) = product ÷ GCF36 × 30 ÷ 6 = 180

For more than two numbers, both are found one number at a time: GCF(a, b, c) = GCF(GCF(a, b), c), and the same for the LCM. The number 1 has no prime factors.

Prime factorization of each number

Prime factorization of each number. Scroll sideways to see all columns.
NumberPrime factors
122² × 3
182 × 3²
302 × 3 × 5

What the GCF and LCM are

The greatest common factor (GCF) of some whole numbers is the largest number that divides all of them with no remainder. It is also called the greatest common divisor (GCD) or highest common factor (HCF). The factors of 12 are 1, 2, 3, 4, 6 and 12; of 18, 1, 2, 3, 6, 9 and 18; the largest they share is 6.

The least common multiple (LCM) is the smallest positive number that every one of them divides into. Multiples of 12 are 12, 24, 36, 48…; of 18, 18, 36, 54…; the first they share is 36.

You use the GCF to simplify a fraction (divide the top and bottom by it) and to split things into the largest equal groups. You use the LCM to find a common denominator and to work out when repeating events line up again. Listing factors or multiples works for small numbers; the two methods below work for any size.

Two methods: prime factors and Euclid’s algorithm

Prime factors. Write each number as a product of primes. The GCF takes the primes that appear in every number, each to the lowest power it has; the LCM takes every prime that appears anywhere, each to the highest power.

GCF = ∏ p^min(exponents) · LCM = ∏ p^max(exponents)

Euclid’s algorithm. Divide the larger number by the smaller and keep the remainder. Then divide the previous divisor by that remainder, and repeat until the remainder is 0. The last non-zero remainder is the GCF. It needs no factoring, so it stays fast for very large numbers. The LCM then follows from the GCF:

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

a, b
two positive whole numbers
p
a prime number (2, 3, 5, 7, 11…)

For three or more numbers, apply either method one number at a time: GCF(a, b, c) = GCF(GCF(a, b), c), and likewise for the LCM.

Worked example: 12, 18 and 30

Prime factors. 12 = 2² × 3, 18 = 2 × 3², 30 = 2 × 3 × 5. The primes in all three are 2 and 3, each at least to the first power, so the GCF is 2 × 3 = 6. Taking every prime at its highest power gives the LCM: 2² × 3² × 5 = 180.

Euclid’s algorithm. For 18 and 12: 18 ÷ 12 = 1 remainder 6, then 12 ÷ 6 = 2 remainder 0, so GCF(12, 18) = 6. Bring in 30: 30 ÷ 6 = 5 remainder 0, so the GCF of all three is 6. For the LCM: LCM(12, 18) = 12 × 18 ÷ 6 = 36, then LCM(36, 30) = 36 × 30 ÷ 6 = 180.

Two numbers: 48 and 180. 180 ÷ 48 = 3 remainder 36; 48 ÷ 36 = 1 remainder 12; 36 ÷ 12 = 3 remainder 0. The GCF is 12 and the LCM is 48 × 180 ÷ 12 = 720. For any two numbers GCF × LCM equals their product: 12 × 720 = 8,640 = 48 × 180.

Things worth knowing

  • A GCF of 1 means “relatively prime”. 8 and 15 share no prime factor, so their GCF is 1 and their LCM is simply 8 × 15 = 120. Neither number has to be prime itself.
  • GCF × LCM = product works only for two numbers. For 12, 18 and 30 the product is 6,480 but GCF × LCM is 6 × 180 = 1,080.
  • Common denominators. The least common denominator of 5/12 and 7/18 is LCM(12, 18) = 36. The fraction calculator finds it for you when adding or subtracting, and the ratio calculator divides by the GCF to simplify ratios such as 12:18 to 2:3.
  • The LCM grows quickly. Ten numbers near a trillion can have an LCM more than 100 digits long, so the calculator works in exact whole-number arithmetic with no size limit on the result.

Limits of this calculator

It accepts 2 to 10 positive whole numbers, each up to one trillion (10¹²). Zero is left out on purpose: every number divides 0, so GCF(a, 0) = a, while the LCM involving 0 is not useful. Negative numbers have the same GCF and LCM as their absolute values, so enter them without the sign. Prime factorization uses trial division, which for numbers up to 10¹² needs at most about a million divisions and runs instantly.

Frequently asked questions

What is the GCF of 12 and 18?

6. Their prime factorizations are 2² × 3 and 2 × 3²; the shared primes at their lowest powers are 2 and 3, and 2 × 3 = 6. Their LCM is 36.

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: the largest whole number that divides all the given numbers exactly.

How do I find the LCM from the GCF?

Multiply the two numbers and divide by their GCF: LCM(a, b) = a × b ÷ GCF(a, b). For 48 and 180 the GCF is 12, so the LCM is 48 × 180 ÷ 12 = 720. For more numbers, repeat one number at a time.

What does it mean if the GCF is 1?

The numbers are relatively prime (coprime): they share no prime factor. Their LCM is then the product of the numbers when there are two of them, for example 8 and 15 have LCM 120.

Why does Euclid’s algorithm work?

Any number that divides both a and b also divides the remainder of a ÷ b, and the reverse is true too. So each division keeps the same common factors while making the numbers smaller, until one of them is 0 and the other is the GCF.

Sources

Last reviewed September 19, 2026