GCF and LCM Calculator
The GCF is the largest number that divides all your numbers and the LCM is the smallest number they all divide into: with 12 = 2^2 × 3, 18 = 2 × 3^2 and 30 = 2 × 3 × 5, the GCF is 2 × 3 = 6 and the LCM is 2^2 × 3^2 × 5 = 180. The working also shows the Euclidean algorithm.
By the Calculators With Steps team · Updated November 10, 2026 · How we check our math
- Greatest common factor (GCF / HCF / GCD)
- 62 × 3
- Least common multiple (LCM)
- 1802² × 3² × 5
- Co-prime (relatively prime)?
- NoThey share the factor 6
Step-by-step working
- Prime factorisation: 12 = 2² × 3; 18 = 2 × 3²; 30 = 2 × 3 × 5
- GCF: take the primes found in every number (2, 3) with their smallest power: 2 × 3 = 6
- LCM: take every prime that appears with its largest power: 2² × 3² × 5 = 180
- Euclidean algorithm for GCF(12, 18): 18 = 1 × 12 + 6; 12 = 2 × 6 + 0. The last non-zero remainder is 6.
- Euclidean algorithm for GCF(6, 30): 30 = 5 × 6 + 0. The last non-zero remainder is 6.
- LCM(12, 18) = 12 × 18 ÷ GCF 6 = 36
- LCM(36, 30) = 36 × 30 ÷ GCF 6 = 180
Prime factorisation of each number
| Number | Prime factors | Number ÷ GCF | LCM ÷ number |
|---|---|---|---|
| 12 | 2² × 3 | 2 | 15 |
| 18 | 2 × 3² | 3 | 10 |
| 30 | 2 × 3 × 5 | 5 | 6 |
How to use the GCF and LCM calculator
Type between 2 and 10 positive whole numbers separated by commas or spaces, for example 12, 18, 30. Do not use thousands separators, because a comma is read as a break between numbers.
The result shows the GCF and LCM together, whether the numbers are co-prime, and a table with each number’s prime factors. The table also lists how many times the GCF fits into each number and how many times each number fits into the LCM, which is exactly what you need when finding a common denominator.
What the GCF and LCM mean
- The greatest common factor (GCF), also called the highest common factor (HCF) or greatest common divisor (GCD), is the largest whole number that divides every number in the list without a remainder.
- The least common multiple (LCM) is the smallest positive whole number that every number in the list divides into exactly.
The GCF can never be larger than the smallest number, and the LCM can never be smaller than the largest number. For 12, 18 and 30, the GCF is 6 and the LCM is 180.
Three ways to find them
1. Prime factorisation. Break each number into primes. The GCF uses only primes common to every number, each with its lowest power. The LCM uses every prime that appears, each with its highest power.
| Number | Prime factors |
|---|---|
| 12 | 2² × 3 |
| 18 | 2 × 3² |
| 30 | 2 × 3 × 5 |
| GCF | 2 × 3 = 6 |
| LCM | 2² × 3² × 5 = 180 |
2. The Euclidean algorithm. Repeatedly divide and keep the remainder. It is fast even for very large numbers because it never needs to factorise them.
| Division | Quotient | Remainder |
|---|---|---|
| 1071 ÷ 462 | 2 | 147 |
| 462 ÷ 147 | 3 | 21 |
| 147 ÷ 21 | 7 | 0 |
The last non-zero remainder, 21, is the GCF of 1071 and 462.
3. The LCM formula using the GCD. For two numbers, LCM(a, b) = a × b ÷ GCF(a, b). For 1071 and 462 that is 1071 × 462 ÷ 21 = 23,562. For a longer list, apply it one pair at a time: LCM(12, 18) = 36, then LCM(36, 30) = 180.
Worked examples
| Numbers | GCF | LCM |
|---|---|---|
| 12, 18 | 6 | 36 |
| 12, 18, 30 | 6 | 180 |
| 48, 180 | 12 | 720 |
| 8, 9 | 1 | 72 |
| 1071, 462 | 21 | 23,562 |
| 1, 2, 3, … 10 | 1 | 2,520 |
Where GCF and LCM are used
Adding fractions. To add 5/12 + 7/18 you need a common denominator, and the smallest one is LCM(12, 18) = 36. Since 36 ÷ 12 = 3 and 36 ÷ 18 = 2, the sum is 15/36 + 14/36 = 29/36. The fraction calculator does this automatically.
Simplifying fractions and ratios. Dividing the top and bottom by the GCF reduces a fraction in one step: 48/180 ÷ 12 = 4/15. The ratio calculator uses the same idea to simplify ratios.
Scheduling. If one bus leaves every 12 minutes and another every 18 minutes, and both leave now, they next leave together in LCM(12, 18) = 36 minutes.
Tiling and cutting. The largest square tile that exactly covers a 48 cm × 180 cm strip without cutting is GCF(48, 180) = 12 cm.
Tips
- If the numbers are co-prime, the LCM is just their product, as with 8 and 9.
- If one number divides all the others, it is the GCF. If one number is a multiple of all the others, it is the LCM.
- The LCM of large numbers can be huge. The calculator uses exact big-integer arithmetic, so every digit of the LCM is correct even when it runs past 16 digits.
GCF and LCM Calculator: frequently asked questions
How do you find the LCM of two numbers?
Divide their product by their GCF: LCM(a, b) = a × b ÷ GCF(a, b). For 12 and 18 the GCF is 6, so the LCM is 12 × 18 ÷ 6 = 216 ÷ 6 = 36.
How do you calculate the LCM of 3 numbers?
Write each number as a product of primes and multiply the highest power of every prime that appears. 12 = 2² × 3, 18 = 2 × 3² and 30 = 2 × 3 × 5, so the LCM is 2² × 3² × 5 = 180.
Is HCF the same as GCF?
Yes. Highest common factor (HCF), greatest common factor (GCF) and greatest common divisor (GCD) are three names for the same number: the largest whole number that divides all the given numbers. The HCF of 12, 18 and 30 is 6.
What is the relationship between HCF and LCM?
For two numbers, HCF × LCM equals the product of the numbers. For 12 and 18, 6 × 36 = 216 = 12 × 18. The rule does not hold for three or more numbers: for 12, 18 and 30, 6 × 180 = 1,080 but 12 × 18 × 30 = 6,480.
What is the LCM of 1 to 10?
The LCM of the numbers 1 through 10 is 2,520, which is 2³ × 3² × 5 × 7. It is the smallest number that every whole number from 1 to 10 divides exactly.
What are co-prime numbers?
Two numbers are co-prime (relatively prime) when their GCF is 1, meaning they share no prime factor. 8 and 9 are co-prime, so their LCM is simply 8 × 9 = 72.
How does the Euclidean algorithm find the GCF?
Divide the larger number by the smaller, then repeat with the smaller number and the remainder until the remainder is 0. For 1071 and 462: 1071 = 2 × 462 + 147, 462 = 3 × 147 + 21, 147 = 7 × 21 + 0, so the GCF is 21.
How do you find the LCM of fractions?
Take the LCM of the numerators and divide by the GCF of the denominators. For 2/3 and 4/9, LCM(2, 4) = 4 and GCF(3, 9) = 3, so the LCM is 4/3.
How we checked this page: every figure in the examples and FAQs above is produced by this calculator and verified by automated tests against known answers, and the rules and rates come from the sources below. Last updated . Spotted a problem? Tell us.
Sources and further reading