Whole numbers (2 to 10)
Whole numbers greater than 0, up to 30 digits each.
GCF (greatest common factor)
LCM (least common multiple)
Step by step
Enter at least two whole numbers to get the GCF and the LCM.
This free GCF and LCM calculator finds the greatest common factor and the least common multiple of 2 to 10 whole numbers at once. Type your numbers and both answers update as you type, together with the steps: the prime factorization of each number, how the GCF and the LCM are built from it and, for two numbers, the Euclidean algorithm and the simplified fraction. Everything runs in your browser and the results stay exact even for very large numbers.
How to use the GCF and LCM calculator
- Type two whole numbers greater than 0, for example 12 and 18.
- Use “Add a number” if you need more, up to 10 numbers. The × button removes a box.
- Read the GCF and the LCM, then follow the steps below them: the prime factors of each number and, for two numbers, the Euclidean algorithm.
- Press “Copy result” to copy both values. Zero, negative numbers, decimals and text are refused with a message that tells you which box to fix.
What are the GCF and the LCM?
The greatest common factor (GCF) is the largest whole number that divides every number in your list without a remainder. The least common multiple (LCM) is the smallest number that every number in your list divides. For 12 and 18, the GCF is 6 and the LCM is 36.
For exactly two numbers, the two results are linked: GCF × LCM = a × b. Here 6 × 36 = 216 and 12 × 18 = 216.
How to find the GCF and the LCM
With prime factorization
Break each number into primes: 12 = 2² × 3 and 18 = 2 × 3². For the GCF, keep the primes found in every number, each with its smallest exponent: 2 × 3 = 6. For the LCM, keep every prime that appears, each with its largest exponent: 2² × 3² = 36.
With the Euclidean algorithm
Divide the larger number by the smaller one and keep the remainder, then repeat with the divisor and that remainder until the remainder is 0. For 18 and 12: 18 = 1 × 12 + 6, then 12 = 2 × 6 + 0. The last divisor, 6, is the GCF. The LCM follows from (12 × 18) ÷ 6 = 36.
With more than two numbers
Take 8, 12 and 20. Their factorizations are 2³, 2² × 3 and 2² × 5. The smallest exponent of 2 is 2, and 3 and 5 are not shared, so the GCF is 2² = 4. Every prime with its largest exponent gives 2³ × 3 × 5 = 120, the LCM.
When the numbers share nothing
8 = 2³ and 15 = 3 × 5 have no prime in common, so their GCF is 1 and their LCM is simply 8 × 15 = 120. Two numbers whose GCF is 1 are called coprime.
Simplifying and adding fractions
When you enter exactly two numbers, the calculator also shows them as a fraction and simplifies it with the GCF. 12/18 divided top and bottom by 6 becomes 2/3. To add fractions with different denominators, use the LCM of the denominators as the common denominator: 1/12 + 1/18 = 3/36 + 2/36 = 5/36, because the LCM of 12 and 18 is 36.
Where you use the GCF and the LCM
- Tiling and cutting: to cover a 120 cm × 90 cm area with identical square tiles and no cutting, the largest possible side is the GCF of 120 and 90, which is 30 cm. That takes 4 × 3 = 12 tiles.
- Schedules: if one bus leaves every 12 minutes and another every 18 minutes, they leave together again after the LCM, 36 minutes.
- Fractions: the GCF reduces a fraction to its simplest form, and the LCM gives the common denominator.
- Homework and exams: check your own working against the prime factors and the Euclidean steps shown by the tool.
Large numbers stay exact
The calculator uses exact integer arithmetic instead of ordinary floating point numbers, so there is no rounding. For example, the LCM of all the numbers from 1 to 20 is 232,792,560. Each number can have up to 30 digits. The prime factorization is shown for numbers up to 10¹²; above that, the GCF and the LCM are still exact but the factors are not listed.
Looking for one result only? Open the GCF calculator or the LCM calculator. Working with proportions? Try the rule of three calculator, or convert numbers with the Roman numeral converter.
Frequently asked questions
What is the difference between the GCF and the LCM?
The GCF is the largest number that divides all your numbers, so it is never bigger than the smallest of them. The LCM is the smallest number that all your numbers divide, so it is never smaller than the biggest of them. For 12 and 18, the GCF is 6 and the LCM is 36.
Is the GCF the same as the GCD or the HCF?
Yes. Greatest common factor (GCF), greatest common divisor (GCD) and highest common factor (HCF) are three names for the same number. In French it is the PGCD and in Spanish the MCD.
How many numbers can I enter?
From 2 to 10 whole numbers, each greater than 0 and up to 30 digits long. With more than two numbers the tool works two at a time, combining the result for the first two with the third, and so on.
What is the GCF of two numbers with no common factor?
It is 1, and the numbers are called coprime. Their LCM is then their product. For 8 and 15, the GCF is 1 and the LCM is 120.
How do I find the LCM from the GCF?
For two numbers, multiply them and divide by their GCF: LCM = (a × b) ÷ GCF. For 12 and 18, that is 216 ÷ 6 = 36. The calculator shows this line in the steps.
Why are zero, negative numbers and decimals refused?
This calculator works with positive whole numbers, which is the case taught in school and used for fractions and schedules. If a box contains zero, a minus sign, a decimal mark or letters, a message names the box so you can correct it.
Are the results exact for very large numbers?
Yes. The calculation uses exact integer arithmetic, so the GCF and the LCM have no rounding, even when the LCM has many more digits than the numbers you typed.
Are my numbers sent anywhere?
No. Everything is calculated in your browser and nothing is uploaded or stored.