๐ข GCF and LCM Calculator: Find the Greatest Common Factor and Least Common Multiple
By Shihab Mia ยท Updated 2026-07-17
Enter two or more whole numbers to find their GCF and LCM.
This GCF and LCM calculator returns both answers at once for any list of whole numbers. The GCF (greatest common factor) is the largest number that divides every value you enter with no remainder. The LCM (least common multiple) is the smallest number that every value divides into evenly. For 12 and 18, the GCF is 6 and the LCM is 36. Type your numbers separated by commas, spaces, or line breaks, and both results appear instantly, along with how many numbers were used. There is no limit of two to six values like most GCF and LCM calculators impose: paste a whole list and the tool folds the calculation across all of it. Below the calculator you will find the prime factorization method, the ladder method, worked examples, and a reference table you can check your homework against.
What is the GCF and LCM Calculator?
The greatest common factor (GCF), also called the greatest common divisor (GCD) or the highest common factor (HCF) in British and Indian textbooks, is the largest whole number that divides evenly into every number in your list. The factors shared by 12 and 18 are 1, 2, 3, and 6, so the GCF is 6. The single most common use is reducing a fraction to lowest terms: dividing the top and bottom of 12/18 by 6 gives 2/3. Any smaller common factor would still leave the fraction reducible, which is why you want the greatest one rather than just any shared factor.
The least common multiple (LCM) is the smallest positive whole number that every number in your list divides into evenly. The multiples of 4 are 4, 8, 12, 16, and so on, while the multiples of 6 are 6, 12, 18, 24. The first value they share is 12, so the LCM of 4 and 6 is 12. The LCM is what you need to find a common denominator when adding or subtracting fractions, and it is also called the lowest common denominator (LCD) when the numbers involved are denominators. Note that the LCM is not always the product: 4 x 6 = 24 is a common multiple, but it is not the least one.
There are three standard hand methods, and this calculator agrees with all of them. Listing method: write out the factors (or multiples) of each number and pick the biggest shared factor (or the smallest shared multiple). It is intuitive but slow past two-digit numbers. Prime factorization method: break each number into primes, then take each shared prime raised to its lowest power for the GCF, and each prime that appears anywhere raised to its highest power for the LCM. With 12 = 2^2 x 3 and 18 = 2 x 3^2, the GCF is 2^1 x 3^1 = 6 and the LCM is 2^2 x 3^2 = 36. Ladder method (also called the cake or box method): divide the whole row by a common prime, write the quotients underneath, and repeat. The GCF is the product of the divisors down the left side, and the LCM is that product times everything left in the bottom row.
Internally the tool uses the Euclidean algorithm rather than factoring, because factoring large numbers is slow while Euclid is nearly instant. The algorithm repeatedly replaces the pair (a, b) with (b, a mod b) until b reaches zero, at which point a is the GCD. It then computes the LCM from the identity lcm(a, b) = a x b / gcd(a, b), which follows because every prime in the product is counted exactly once between the two results. For a list of three or more values, both operations are folded pairwise: gcd(a, b, c) = gcd(gcd(a, b), c), and the same associativity holds for the LCM. This is why a GCF and LCM calculator can handle a dozen numbers as fast as two.
A few boundary rules are worth knowing because they trip people up and because different textbooks state them differently. If two numbers share no factor beyond 1 they are called coprime or relatively prime, so the GCF is 1 and the LCM is simply their product: gcf(7, 11) = 1 and lcm(7, 11) = 77. If one number divides the other, the GCF is the smaller number and the LCM is the larger: gcf(6, 18) = 6 and lcm(6, 18) = 18. The GCF of any number with itself is that number. By convention gcd(n, 0) = n, since every number divides zero, but the LCM with zero is undefined or zero depending on the source, which is why this calculator ignores zeros rather than guessing. Decimals and negative signs are also stripped, because both the GCF and the LCM are defined for positive whole numbers.
The relationship GCF x LCM = a x b is one of the most useful shortcuts in the topic, and also one of the most misapplied. It is exactly true for two numbers, so if a test question tells you the GCF of two numbers is 6 and their LCM is 36, you know their product is 216, which narrows the candidates to 6 and 36 or 12 and 18. It is false for three or more numbers: gcf(12, 18, 24) x lcm(12, 18, 24) = 6 x 72 = 432, while the product of the three numbers is 5184. Use the pairwise fold instead, which is exactly what this calculator does for every input beyond two values.
When to use it
- Reducing a fraction to lowest terms by dividing the numerator and denominator by their GCF, for example 42/56 with a GCF of 14 becomes 3/4.
- Finding the lowest common denominator when adding or subtracting fractions, which is the LCM of the denominators.
- Checking GCF and LCM homework answers before you submit, and seeing which of the two you swapped when they disagree.
- Working out when two repeating events line up again, such as buses arriving every 12 and 18 minutes both leaving together after 36 minutes.
- Splitting two quantities into the largest possible equal groups, such as 24 pencils and 36 erasers packed into 12 identical kits.
- Simplifying a ratio, since dividing every term of 18:24:30 by the GCF of 6 gives the equivalent ratio 3:4:5.
How to use the GCF and LCM Calculator
- Type two or more whole numbers, separated by commas, spaces, or new lines. There is no upper limit on how many you enter.
- Read the GCF (greatest common factor) and the LCM (least common multiple) shown straight away. No submit button is needed.
- Check the count of numbers used to confirm the tool read every value you pasted.
- Use one of the example buttons to load a sample set, or Clear to start over.
- Decimals, negative signs, and zeros are handled automatically, since only positive whole numbers are used in the calculation.
Formula & method
Worked examples
Find the GCF and LCM of 12 and 18 by both the Euclidean and the prime factorization methods.
- Euclid: gcd(12, 18) = gcd(18, 12) = gcd(12, 6) = gcd(6, 0) = 6
- LCM from the identity: 12 x 18 / 6 = 216 / 6 = 36
- Check by primes: 12 = 2^2 x 3 and 18 = 2 x 3^2
- GCF = lowest power of each shared prime = 2^1 x 3^1 = 6
- LCM = highest power of every prime present = 2^2 x 3^2 = 36
Result: GCF = 6, LCM = 36 (both methods agree)
Add 5/8 + 7/12 using the LCM as the common denominator.
- Find the LCM of the denominators: gcd(8, 12) = 4, so lcm(8, 12) = 8 x 12 / 4 = 24
- Rewrite each fraction over 24: 5/8 = 15/24 and 7/12 = 14/24
- Add the numerators: 15/24 + 14/24 = 29/24
- Check whether it reduces: gcd(29, 24) = 1, so it is already in lowest terms
Result: 5/8 + 7/12 = 29/24, or 1 and 5/24
Find the GCF and LCM of three numbers: 12, 18, and 24.
- GCF pairwise: gcd(12, 18) = 6, then gcd(6, 24) = 6
- LCM pairwise: lcm(12, 18) = 36, then lcm(36, 24) = 36 x 24 / gcd(36, 24) = 864 / 12 = 72
- Note the shortcut fails here: 6 x 72 = 432, not 12 x 18 x 24 = 5184
Result: GCF = 6, LCM = 72
GCF and LCM for the number pairs that come up most in homework
| Numbers | GCF | LCM | Note |
|---|---|---|---|
| 4 and 6 | 2 | 12 | LCM is less than the product 24 |
| 6 and 8 | 2 | 24 | Both even, so GCF is at least 2 |
| 8 and 12 | 4 | 24 | GCF x LCM = 96 = 8 x 12 |
| 9 and 12 | 3 | 36 | Only 3 is shared |
| 10 and 15 | 5 | 30 | Shared prime is 5 |
| 12 and 18 | 6 | 36 | The classic textbook pair |
| 16 and 24 | 8 | 48 | GCF is a power of 2 |
| 6 and 18 | 6 | 18 | One divides the other |
| 7 and 11 | 1 | 77 | Coprime, so LCM is the product |
| 15 and 28 | 1 | 420 | Coprime despite both being composite |
Which method to use, and when
| Method | How it works | Best for | Weakness |
|---|---|---|---|
| Listing | Write out all factors or multiples and pick the shared one | Numbers under about 30, and first learning the idea | Very slow and error prone for larger numbers |
| Prime factorization | Shared primes at lowest power give the GCF, all primes at highest power give the LCM | Showing your work, and any set of three or more numbers | Factoring large numbers by hand is hard |
| Ladder or cake | Divide the row by common primes; left column gives the GCF, left column times bottom row gives the LCM | Getting both answers from one piece of work | Easy to forget to carry down a non divisible number |
| Euclidean algorithm | Replace (a, b) with (b, a mod b) until b = 0 | Large numbers and computer code, and what this tool uses | Gives the GCF only, so the LCM needs one extra step |
Prime factorization of common numbers, for the factorization method
| Number | Prime factorization |
|---|---|
| 8 | 2^3 |
| 12 | 2^2 x 3 |
| 15 | 3 x 5 |
| 18 | 2 x 3^2 |
| 24 | 2^3 x 3 |
| 30 | 2 x 3 x 5 |
| 36 | 2^2 x 3^2 |
| 45 | 3^2 x 5 |
| 48 | 2^4 x 3 |
| 60 | 2^2 x 3 x 5 |
| 72 | 2^3 x 3^2 |
| 100 | 2^2 x 5^2 |
Common mistakes to avoid
- Mixing up the GCF and the LCM. The GCF is never larger than the smallest number you entered, and the LCM is never smaller than the largest. If your answer breaks that rule you have swapped them. A quick sanity check on 12 and 18: any answer above 12 cannot be the GCF, and any answer below 18 cannot be the LCM.
- Assuming GCF times LCM equals the product for three or more numbers. The identity GCF x LCM = a x b holds only for exactly two numbers. For 12, 18, and 24 the GCF is 6 and the LCM is 72, giving 432, while the product of the three numbers is 5184. With three or more values, fold the GCF and the LCM pairwise across the list, as this tool does.
- Taking the highest power of shared primes for the GCF. In the prime factorization method the GCF uses the lowest power of each shared prime and the LCM uses the highest power of every prime present. For 12 = 2^2 x 3 and 18 = 2 x 3^2, the GCF is 2^1 x 3^1 = 6, not 2^2 x 3^2 = 36. Reversing the two rules is the single most common factorization error.
- Assuming the LCM is always the product of the numbers. The LCM equals the product only when the numbers are coprime. For 4 and 6 the product is 24 but the LCM is 12, because they share a factor of 2. Multiplying denominators always gives a common denominator, but often not the lowest one, which leaves you extra reducing to do.
- Forgetting that coprime numbers have a GCF of 1. When two numbers share no factor other than 1, such as 7 and 11 or 15 and 28, the GCF is 1 and the LCM is their product. A GCF of 1 is a valid answer, not a sign the calculator failed. It means the fraction is already in lowest terms.
- Including zero or decimals in the list. Zero is a multiple of every number, so it has no meaningful LCM with other values, and the GCF and LCM are defined only for positive whole numbers. This tool ignores zeros, decimals, and negative signs so the result stays well defined rather than returning a misleading number.
Glossary
- Greatest common factor (GCF)
- The largest whole number that divides evenly into every number in a set. Also called the greatest common divisor (GCD) or, in British and Indian textbooks, the highest common factor (HCF).
- Least common multiple (LCM)
- The smallest positive whole number that every number in a set divides into evenly. Also called the lowest common multiple.
- Lowest common denominator (LCD)
- The LCM of the denominators of two or more fractions. It is the smallest denominator you can rewrite them all over before adding or subtracting.
- Euclidean algorithm
- A fast method for finding the GCD: repeatedly replace the pair (a, b) with (b, a mod b) until the remainder is zero. The last nonzero value is the GCD.
- Prime factorization
- Writing a number as a product of primes, such as 12 = 2 x 2 x 3. Every whole number above 1 has exactly one prime factorization, which is why the method always works.
- Coprime
- Two numbers are coprime, or relatively prime, when their only common factor is 1. Their GCF is 1 and their LCM is their product.
- Ladder method
- Also called the cake or box method. Divide a row of numbers by a common prime and write the quotients below, repeating until nothing is shared. The left column multiplies to the GCF; the left column times the bottom row gives the LCM.
- Modulo (mod)
- The remainder after division. 18 mod 12 = 6, because 18 divided by 12 leaves 6. The Euclidean algorithm is built entirely on this operation.
Frequently asked questions
What is the GCF of two numbers?
The GCF (greatest common factor) is the largest whole number that divides both numbers exactly. For 12 and 18 the GCF is 6, because 6 is the biggest number that goes into both without a remainder. It is also called the GCD or HCF.
What is the LCM of two numbers?
The LCM (least common multiple) is the smallest positive number that both numbers divide into evenly. For 4 and 6 the LCM is 12, the first value that appears in both lists of multiples. It is not always the product of the two numbers.
What is the difference between GCF and LCM?
The GCF is the largest factor shared by the numbers, so it is at most as big as the smallest input. The LCM is the smallest common multiple, so it is at least as big as the largest input. Use the GCF to simplify fractions and the LCM to find a common denominator.
How do you find the GCF and LCM together?
Find the GCF first, usually with the Euclidean algorithm or prime factorization, then use lcm(a, b) = a x b / gcf(a, b). The ladder method gives both from one piece of work: the left column multiplies to the GCF, and the left column times the bottom row gives the LCM. This calculator does both at once.
What is the GCF and LCM of 12 and 18?
The GCF of 12 and 18 is 6 and the LCM is 36. Since 12 = 2^2 x 3 and 18 = 2 x 3^2, the shared primes at their lowest powers give 2 x 3 = 6, and every prime at its highest power gives 2^2 x 3^2 = 36.
Is HCF the same as GCF?
Yes. HCF (highest common factor), GCF (greatest common factor), and GCD (greatest common divisor) all name the same value. HCF is standard in British and Indian curricula, GCF in US textbooks, and GCD in computer science and number theory.
Does GCF times LCM always equal the product of the numbers?
Only for exactly two numbers. For any pair, gcf(a, b) x lcm(a, b) = a x b, so gcf(8, 12) x lcm(8, 12) = 4 x 24 = 96 = 8 x 12. For three or more numbers the identity fails: gcf(12, 18, 24) x lcm(12, 18, 24) = 432, but 12 x 18 x 24 = 5184.
Can the GCF be 1?
Yes. When numbers share no common factor other than 1 they are called coprime, so the GCF is 1 and the LCM is simply their product. This is true for 7 and 11, and also for 15 and 28 even though both are composite. A GCF of 1 means a fraction is already in lowest terms.
Does the calculator work for more than two numbers?
Yes, and with no cap. Enter any list of whole numbers and the tool folds the GCF and LCM across all of them one pair at a time, giving a single GCF and a single LCM for the whole set. Many competing calculators limit you to between two and six values.
How do I use the GCF to simplify a fraction?
Divide both the numerator and the denominator by their GCF. For 42/56, the GCF is 14, so 42 / 14 = 3 and 56 / 14 = 4, giving 3/4. Using the greatest common factor rather than any shared factor gets you to lowest terms in one step.