Calculate the Least Common Multiple (LCM) and Greatest Common Factor (GCF) of numbers.
Reviewed by the CalculatorKosh Editorial TeamUpdated June 2026Free ยท No sign-up
LCM and GCF Calculator
Calculate the Least Common Multiple (LCM) and Greatest Common Factor (GCF) of numbers.
3 valid numbers ยท Max value: 1,000,000
Prime factorizations
How It Works
This calculator finds the LCM and the GCF of two or more whole numbers at once, then shows the working so you can learn the method, not just copy the answer. The LCM (Least Common Multiple) is the smallest positive number that every input divides into evenly. The GCF (Greatest Common Factor) โ also called the GCD, Greatest Common Divisor, or HCF, Highest Common Factor โ is the largest number that divides every input without a remainder. It is built for school and competitive-exam students, parents helping with homework, and anyone who needs to add fractions, simplify ratios, or line up repeating cycles.
Method 1 โ prime factorization
Break each number into its prime building blocks, that is, primes such as 2, 3, 5, 7 multiplied together. Take 12, 18 and 24: 12 = 2ยฒ ร 3, 18 = 2 ร 3ยฒ, and 24 = 2ยณ ร 3. The rule is symmetrical and easy to remember. For the GCF, take every prime the numbers share and use the smallest exponent that appears: 2 appears as 2ยน at minimum (in 18) and 3 appears as 3ยน at minimum, so GCF = 2 ร 3 = 6. For the LCM, take every prime that appears in any number and use the largest exponent: the biggest power of 2 is 2ยณ (in 24) and the biggest power of 3 is 3ยฒ (in 18), so LCM = 2ยณ ร 3ยฒ = 8 ร 9 = 72. The calculator prints each prime factorization so you can check this line by line.
Method 2 โ the Euclidean algorithm
For two large numbers, prime factorization is slow, so this tool also uses the Euclidean algorithm, which is far faster. It relies on a neat fact: GCF(a, b) = GCF(b, a mod b), where "a mod b" is the remainder when a is divided by b. Keep replacing the pair until the remainder is zero, and the last non-zero number is the GCF. For 48 and 18: GCF(48, 18) โ GCF(18, 12) โ GCF(12, 6) โ GCF(6, 0) = 6. Once the GCF is known, the LCM follows instantly from the identity below.
The key relationship
For any two positive integers, LCM(a, b) ร GCF(a, b) = a ร b. This means once you have one, the other is a single step away: LCM(a, b) = (a ร b) รท GCF(a, b). Using 12 and 18, GCF is 6, so LCM = (12 ร 18) รท 6 = 216 รท 6 = 36 โ and indeed 6 ร 36 = 216 = 12 ร 18, which is exactly the verification line the calculator shows for two-number inputs. Note this product identity holds for pairs; with three or more numbers the calculator extends the result by folding the operation across the list one number at a time.
Worked example โ adding fractions
To add 1/12 + 1/18 you need a common denominator, and the smallest one is the LCM of 12 and 18, which is 36. Rewrite each fraction: 1/12 = 3/36 and 1/18 = 2/36, so the sum is 5/36. Because 5 and 36 share no common factor (their GCF is 1), 5/36 is already in lowest terms. The GCF does the reverse job โ to simplify 18/24, divide top and bottom by GCF(18, 24) = 6 to get 3/4.
Tips and common mistakes
The most common error is swapping the two: GCF is never larger than your smallest number, while LCM is never smaller than your largest. If your "GCF" exceeds an input, you have computed the LCM by mistake. When the GCF comes out as 1, the numbers are coprime (they share no factor but 1), and the LCM is simply their product โ for example 8 and 9 give LCM 72. Watch the exponent rule carefully: GCF takes the minimum power and only primes common to all, whereas LCM takes the maximum power and every prime that appears. This tool works with positive integers only; it ignores zero, negatives and decimals, since LCM and GCF are defined for whole numbers.
Frequently Asked Questions
LCM use cases: finding a common denominator for fractions, scheduling repeating events (two buses arriving every 6 and 9 minutes โ both arrive together every 18 min). GCF use cases: simplifying fractions, dividing objects into equal groups without remainder, finding the largest tile size for a room.
Part of Algebra & Numbers Calculators โ compare every related calculator in one place.