LCM and GCF calculator
Enter whole numbers, get the least common multiple and greatest common factor.
Two or more whole numbers, separated by commas or spaces.
How do I find the greatest common factor?
Find the largest number that divides all of them. For 12, 18 and 30 it is 6. With prime factors: 12 = 2² × 3, 18 = 2 × 3², 30 = 2 × 3 × 5 — the primes they all share, at the lowest power, are 2 × 3 = 6.
How do I find the least common multiple?
Take every prime at its highest power. For 12, 18 and 30: 2² × 3² × 5 = 180. It is the smallest number all three divide into.
What is the LCM of 4 and 6?
12. The multiples of 4 are 4, 8, 12… and of 6 are 6, 12… — 12 is the first they share. For two numbers, LCM = a × b ÷ GCF: 4 × 6 ÷ 2 = 12.
What is the GCF used for?
Simplifying fractions and ratios: 12/18 ÷ 6/6 = 2/3. The LCM gives the common denominator for adding fractions, like 12 for 1/4 + 1/6.
Is GCF the same as GCD and HCF?
Yes. Greatest common factor, greatest common divisor and highest common factor are three names for the same number.
What if the GCF is 1?
Then the numbers are called relatively prime (coprime): they share no prime factor, even if none of them is prime itself. 8 and 15 are an example. For coprime numbers the LCM is simply their product, 8 × 15 = 120, and a fraction such as 8/15 is already in lowest terms.
Can I find the LCM of more than two numbers?
Yes. Take the LCM of the first two, then the LCM of that result with the third, and so on. The shortcut LCM = product ÷ GCF works only for two numbers; it fails for three or more, as the worked example below shows.
Which one do I use for a word problem?
Use the LCM when events repeat and you want the first time they line up (buses, gears, schedules) or when you need a common denominator. Use the GCF when you split things into equal groups with nothing left over, or when you want the largest square tile that fits a floor.
Two ways to compute them
Prime factorization writes each number as a product of primes. The GCF multiplies the primes that appear in every number, each at its lowest power; the LCM multiplies every prime that appears in any number, each at its highest power. This is the method the calculator shows in its table. For large numbers the Euclidean algorithm is faster, and it is the one that avoids factoring at all: replace the pair (a, b) with (b, a mod b) until the remainder is 0, and the last nonzero value is the GCF. The LCM of two numbers then follows from LCM = a × b ÷ GCF.
Worked examples
Euclid’s algorithm on 1071 and 462: 1071 = 2 × 462 + 147, then 462 = 3 × 147 + 21, then 147 = 7 × 21 + 0. The last nonzero remainder is 21, so the GCF is 21, and the LCM is 1071 × 462 ÷ 21 = 23,562.
Three numbers, 12, 18 and 30: the GCF is 6 and the LCM is 180. Applying the two-number shortcut, 12 × 18 × 30 ÷ 6, would give 1,080, which is a common multiple but not the least one, so work pairwise or by prime factors instead.
Schedule problem: one bus leaves every 12 minutes and another every 18 minutes. They leave together again after the LCM, 36 minutes.
Things to watch
- Only positive whole numbers are accepted, from 1 up to 1,000,000,000,000. Decimals, zero and negative values are ignored; for decimals, scale them to whole numbers first (0.75 and 1.5 become 75 and 150).
- The LCM grows fast, and when it exceeds the largest integer a browser can hold exactly (about 9 × 10¹⁵) the calculator reports “too large” instead of a rounded figure.
- Do not mix up the two: the GCF is never larger than the smallest number, and the LCM is never smaller than the largest one.
- Check the separators: use commas or spaces, and leave a thousands separator out of the numbers.
Sources: Euclid, Elements, Book VII (propositions 1 and 2 for the Euclidean algorithm); standard number theory texts for the prime-factor method and gcd × lcm identity. Related tools: factor calculator, prime number calculator, fraction calculator.