What is the GCF and LCM Calculator?
This tool computes the greatest common factor (GCF) — also called the greatest common divisor (GCD) or highest common factor (HCF) — and the least common multiple (LCM) of two whole numbers. 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 are universal arithmetic concepts and apply everywhere.
How to use it
Enter your two positive integers in the boxes for a and b, then read the GCF in the highlighted box and the LCM in the table below. The calculator handles any pair of whole numbers and returns results instantly.
The formula explained
The GCF is found with the Euclidean algorithm: repeatedly replace the pair (a, b) with (b, a mod b) until the second number becomes zero. The remaining first number is the GCF. Once the GCF is known, the LCM follows from the identity $$\text{lcm}(\text{a},\,\text{b}) = \frac{\text{a} \times \text{b}}{\gcd(\text{a},\,\text{b})}$$ This works because the product of two numbers equals the product of their GCF and LCM.
Worked example
Take \(a = 12\) and \(b = 18\). Euclid: \(\gcd(12, 18) \to \gcd(18, 12) \to \gcd(12, 6) \to \gcd(6, 0) = 6\), so the GCF is 6. Then $$\text{LCM} = 12 \times 18 \div 6 = 216 \div 6 = 36$$ So \(\text{GCF} = 6\) and \(\text{LCM} = 36\).
FAQ
Are GCF and GCD the same thing? Yes — greatest common factor, greatest common divisor, and highest common factor all mean the same number.
What if one number is a multiple of the other? Then the smaller number is the GCF and the larger is the LCM. For example, \(\text{GCF}(4, 12) = 4\) and \(\text{LCM}(4, 12) = 12\).
Can I use it for prime numbers? Yes. For two different primes the GCF is always 1 and the LCM is their product.