LCM and GCF Calculator
Find the least common multiple and greatest common factor (HCF, GCD) of two or more numbers, with the method.
3 numbers
Separate numbers with commas, spaces or new lines. A comma always separates, so write 1234, not 1,234.
180
6
Divide by the smallest prime that goes into any of the numbers, bringing down the ones it does not divide, until every number is 1.
| 2* | 12 | 18 | 30 |
|---|---|---|---|
| 2 | 6 | 9 | 15 |
| 3* | 3 | 9 | 15 |
| 3 | 1 | 3 | 5 |
| 5 | 1 | 1 | 5 |
| 1 | 1 | 1 |
- Multiply all the divisors for the LCM.2 × 2 × 3 × 3 × 5 = 180
- Multiply the divisors marked *, which went into every number of their row, for the GCF.2 × 3 = 6
Enter two or more whole numbers to get their least common multiple and their greatest common factor together: for 12, 18, 30, an LCM of 180 and a GCF of 6. The working is shown by the method you were taught, with your own numbers.
The greatest common factor goes by three names. GCF, HCF (highest common factor, the usual name in India and the UK) and GCD (greatest common divisor) are the same number.
How to use it
Numbers takes 2 to 20 whole numbers of up to 30 digits each, separated by commas, spaces or new lines. A comma always separates, so write 1234, not 1,234. Signs are ignored: the results are for the absolute values.
Working by chooses the method shown under the results, and is remembered on your device:
- Division — the ladder that divides all the numbers at once by primes, drawn for up to 40 divisions.
- Prime factors — each number as a product of primes, then the highest and lowest powers.
- Euclid — repeated division, two numbers at a time.
- Listing — the multiples and factors of each number written out, when the LCM is 200 or less.
The results themselves always come from Euclid’s algorithm, which is immediate at any size. The first two methods need every number factored into primes; if that takes more than 2 seconds, which can happen with very large numbers, they are left out. Everything runs in your browser.
How it works
Common division. Write the numbers in a row. Divide by the smallest prime that goes into at least one of them, write the results underneath, and bring down any number it does not divide. Repeat until the row is all 1s. The LCM is the product of every divisor used. The GCF is the product of only those divisors that went into every number of their row, which the tool marks with *.
Prime factorization. Factor each number. The LCM takes every prime that appears, at the highest power it reaches in any number; the GCF takes only the primes present in every number, at the lowest power.
Euclid’s algorithm. Divide the larger number by the smaller, then the smaller by the remainder, and so on until the remainder is 0; the last divisor is the GCF. The LCM follows from the product. With more than two numbers, the result so far is paired with the next number.
LCM(a, b) = a × b ÷ GCF(a, b)
GCF(a, b, c) = GCF(GCF(a, b), c)
LCM(a, b, c) = LCM(LCM(a, b), c)
Examples
LCM and GCF of 12, 18, 30 by prime factors
With 12, 18, 30 and Prime factors, the LCM is 180 and the GCF is 6:
- Write 12 as a product of primes. 12 = 2² × 3
- Write 18 as a product of primes. 18 = 2 × 3²
- Write 30 as a product of primes. 30 = 2 × 3 × 5
- For the LCM, take every prime that appears, at its highest power. 2² × 3² × 5 = 180
- For the GCF, take the primes that appear in every number, at their lowest power. 2 × 3 = 6
Two bells ringing together
One bell rings every 12 minutes and another every 18. They ring together at every common multiple of the two, so first after the LCM of 12, 18, which is 36 minutes. By Euclid:
- Divide the larger of 12 and 18 by the smaller, then the divisor by the remainder, until nothing is left over. The last divisor is their GCF. 18 = 1 × 12 + 6, 12 = 2 × 6 + 0, so GCF = 6
- The LCM of two numbers is their product divided by their GCF, here 6. 12 × 18 ÷ 6 = 36
LCM × GCF = 36 × 6 = 216, the same as 12 × 18.
Cutting two ropes into equal pieces
Ropes of 48 m and 60 m are to be cut into pieces of one length, as long as possible, with nothing left over. The length must divide both, so it is the GCF of 48, 60: 12 m. With Division, the ladder divides by 2, 2, 2, 2, 3, 5, and of those 2, 2, 3 go into both numbers of their row:
- Multiply all the divisors for the LCM. 2 × 2 × 2 × 2 × 3 × 5 = 240
- Multiply the divisors marked *, which went into every number of their row, for the GCF. 2 × 2 × 3 = 12
Frequently asked questions
See also
- Prime Factorization Calculator — for the factor tree and every factor of one number.
- Fraction Calculator — to add fractions, which uses the LCM of their denominators.
- Ratio Calculator — to simplify a ratio by the GCF of its terms.