LCM and GCF Calculator
Get the greatest common factor (GCF, also called GCD or HCF) and least common multiple (LCM) of up to 20 numbers, with prime factorizations.
Result
Enter your values and select Calculate to see the result.
How to use this calculator
- Enter between 2 and 20 positive whole numbers, separated by commas or spaces.
- The result shows the GCF and LCM, and a prime factorization of each number.
Formula
The GCF is found with Euclid’s algorithm: gcd(a, b) = gcd(b, a mod b) until the remainder is 0. For more than two numbers it is applied repeatedly.
lcm(a, b) = a × b ÷ gcd(a, b), also applied repeatedly.
With prime factorizations: the GCF uses the lowest power of each prime that appears in every number, and the LCM uses the highest power of every prime.
Worked example
12, 18 and 30
12 = 2² × 3, 18 = 2 × 3², 30 = 2 × 3 × 5.
GCF = 2 × 3 = 6. LCM = 2² × 3² × 5 = 180.
Assumptions and limitations
- Only positive whole numbers are accepted.
- The LCM is calculated with arbitrary-precision integers, so it stays exact even when it is very large.
- Prime factorizations are shown for numbers up to one trillion.
Frequently asked questions
Where is the LCM used?
Finding a common denominator when adding fractions, and working out when repeating events coincide — for example buses every 12 and 18 minutes meet every 36 minutes.
What if the GCF is 1?
The numbers are called coprime: they share no prime factors, and their LCM is simply their product.