What is the GCF and LCM Calculator?
This calculator finds two fundamental quantities for any pair of whole numbers: the Greatest Common Factor (GCF) — also called the greatest common divisor (GCD) — and the Least Common Multiple (LCM). The GCF is the largest number that divides both inputs evenly, while the LCM is the smallest number that both inputs divide into evenly. These appear constantly when simplifying fractions, finding common denominators, and solving number-theory problems.
How to use it
Enter your two whole numbers in the First number and Second number fields and submit. The calculator returns the GCF in the hero box, plus the LCM and the product of the two numbers in the table below. Both values are computed instantly using Euclid's algorithm, which is fast even for very large numbers.
The formula explained
The GCF is computed with Euclid's algorithm: repeatedly replace the pair \((a,\ b)\) with \((b,\ a \bmod b)\) until the second value reaches zero; the remaining value is the GCF. Once the GCF is known, the LCM follows from a neat identity:
$$\text{LCM}(a,\ b) = \frac{a \times b}{\text{GCF}(a,\ b)}$$
This works because the product of two numbers always equals the product of their GCF and LCM.
Worked example
Take \(a = 12\) and \(b = 18\). Euclid's algorithm: \(18 \bmod 12 = 6\), then \(12 \bmod 6 = 0\), so the GCF \(= 6\). The LCM is then $$\frac{12 \times 18}{6} = \frac{216}{6} = 36.$$ So \(\text{GCF}(12,\ 18) = 6\) and \(\text{LCM}(12,\ 18) = 36\).
FAQ
What's the difference between GCF and GCD? They are the same thing — "greatest common factor" and "greatest common divisor" are interchangeable terms.
Can I enter decimals? GCF and LCM are defined for whole numbers (integers). Decimals are rounded down to integers before calculation.
What if one number is zero? Mathematically the GCF of any number and 0 is that number, but the LCM is undefined; use positive whole numbers for meaningful results.