GCF and LCM Calculator
Find common factors and multiples through prime factorization or the Euclidean algorithm, with sign and zero cases handled.
Drag & drop or upload an image or PDF
Enter two or more whole numbers separated by commas, such as 84, 126.
Try an example
Common divisors and common multiples answer different questions
The greatest common divisor is the largest positive integer that divides every input without a remainder. GCF and HCF are common alternative names for the same value.
The least common multiple is the smallest positive number divisible by every nonzero input. Prime factorization shows both answers at once: the GCD uses the lowest shared exponents, while the LCM uses the highest exponents that appear.
How to use the gcf and lcm calculator
Enter the problem as written
Type or paste the full expression. You can also upload a clear photo or PDF and check the extracted text before solving.
Read the working, not only the answer
Each transformation is separated and explained so you can compare it with your own method.
Ask about any step
Continue in the same solution to request another method, check a restriction, or ask why a rule applies.
Product relationship for two nonzero integers
Once either the GCD or LCM is known, this identity provides the other and offers a useful check.
A reliable way to work through it
Compare prime factors
Use the lowest common prime powers for the GCD and the highest prime powers present for the LCM.
Use the Euclidean algorithm
Repeatedly replace the larger pair with the divisor and remainder until the remainder is zero.
Combine a longer list
Find the result for the first two integers, then combine it with each remaining integer in turn.
Worked example
Find the GCD and LCM of 84 and 126
Write 84 as a product of primes.
Write 126 using the same prime bases.
Take the smaller exponent for every shared prime.
Take the largest exponent that appears in either factorization.
The GCD is 42 and the LCM is 252.
Common mistakes to check
Using the largest exponents for the GCD
The GCD contains only factors shared by every input, so it uses the smallest shared exponent.
Confusing GCD with LCM
A divisor goes into each number. A common multiple is divisible by each number.
Ignoring zero cases
The GCD of a and zero is the absolute value of a, while the LCM of a and zero is zero when a is nonzero.
Related calculators
Questions students ask
Are GCD, GCF, and HCF the same thing?
Yes. They are different names for the greatest positive integer that divides all supplied integers.
Can I enter more than two numbers?
Yes. The GCD or LCM can be combined pair by pair across any finite list of integers.
How are negative inputs handled?
Signs do not change divisibility, so GCD and LCM are conventionally reported as nonnegative values using absolute values.
Which method is better for large numbers?
The Euclidean algorithm is usually faster for the GCD. The product relationship can then provide the LCM for two integers.