How to use the gcf and lcm calculator
- Type two to eight whole numbers, separated by commas, spaces or new lines.
- Read the greatest common factor (GCF) and the least common multiple (LCM).
- Open the steps to follow the Euclidean algorithm, and check the prime factorization table.
Formula
GCF(a, b): repeat a = q x b + r, then replace (a, b) by (b, r) until r = 0
LCM(a, b) = a x b / GCF(a, b)
From primes: GCF takes the lowest power of each shared prime, LCM takes the highest power of every prime
For more than two numbers the tool applies the rule to the running result, one number at a time. The answer does not depend on the order.
Worked examples
12, 18 and 30. The prime factorizations are 12 = 2² x 3, 18 = 2 x 3² and 30 = 2 x 3 x 5. The shared primes are 2 and 3 with lowest powers 1 and 1, so the GCF is 6. Taking the highest power of every prime gives 2² x 3² x 5 = 180, the LCM.
Euclid on 48 and 18. 48 = 2 x 18 + 12, then 18 = 1 x 12 + 6, then 12 = 2 x 6 + 0. The last nonzero remainder is 6, so the GCF is 6 and the LCM is 48 x 18 / 6 = 144.
17 and 13 share no prime factor, so the GCF is 1 and they are relatively prime. The LCM is simply 17 x 13 = 221.
8, 12, 20 and 28 have GCF 4. The LCM chain is lcm(8, 12) = 24, then lcm(24, 20) = 120, then lcm(120, 28) = 840.
Where each one is used
The GCF is used to simplify fractions, since dividing the top and bottom by it gives lowest terms, and to split things into the largest equal groups. The LCM is used to find a common denominator when adding fractions, and to find when repeating cycles line up, such as two buses that leave every 12 and 18 minutes meeting again after 36 minutes. To work with fractions directly, use the fraction calculator.
Prime factorization by trial division
Each number is divided by 2, then by odd numbers up to its square root. For numbers up to 1,000,000,000,000 that takes at most about half a million quick checks, so the answer appears instantly. The tool also recomputes the GCF and LCM from the prime factors and checks that both methods agree.
Very large LCM values
The LCM of several large numbers can be enormous. It is computed with exact big-integer arithmetic and shown with thousands separators, so there is no rounding. For counting arrangements of items, see the combinations and permutations calculator, and for scaling quantities by a ratio use the ratio calculator.
Assumptions and limits
- Only positive whole numbers up to 1,000,000,000,000 are accepted. Zero, negatives and decimals are rejected with a message.
- You can enter two to eight numbers.
- The GCF of one number alone is not calculated, so at least two numbers are required.
- Results are exact integers with no rounding.
- All calculations happen in your browser.
Frequently asked questions
What is the difference between GCF and LCM?
The GCF is the largest number that divides all of your numbers evenly, so it is never larger than the smallest one. The LCM is the smallest number that all of them divide into evenly, so it is never smaller than the largest one.
How do I find the GCF of three numbers?
Find the GCF of the first two, then find the GCF of that result and the third number. Repeating the step handles any count, and the order does not matter.
What does it mean when the GCF is 1?
The numbers are relatively prime, or coprime. They share no prime factor even if none of them is prime itself, as with 8 and 15.
Is there a shortcut from GCF to LCM for two numbers?
Yes. Multiply the two numbers and divide by their GCF. For 12 and 18 that is 216 / 6 = 36. This shortcut works only for two numbers at a time.
Why is the Euclidean algorithm so fast?
Each step replaces the pair with a remainder that is smaller than half the larger number every two steps, so even numbers with twelve digits need only a few dozen divisions.