About GCD & LCM Calculator
The greatest common divisor is the largest number that divides all of yours evenly, and the least common multiple is the smallest number they all divide into. The first simplifies fractions and splits things into equal groups. The second finds when repeating events line up, or a common denominator. Enter your numbers and both appear as you type.
Results come with the working, written as Euclid's algorithm line by line and as a table of prime factors. That makes this useful for checking homework, since you can compare your method and not only your answer. In some countries the GCD is called HCF, the highest common factor, and it means the same thing.
How it works
The GCD uses Euclid's algorithm: divide the larger number by the smaller, keep the remainder, and repeat until the remainder is zero. For two or more numbers, it folds through the list, so the GCD of three numbers is the GCD of the first two with the third. For 48 and 18, the GCD is 6 and the LCM is 144.
The LCM comes from the GCD, using lcm(a, b) = a ÷ gcd(a, b) × b. Everything runs on arbitrary precision integers, because LCMs grow very quickly and can pass the 16 digit limit of ordinary calculators after only a few inputs. Prime factors are found by trial division for numbers up to 100 trillion. Larger ones still get an exact GCD and LCM, but the table says they are too large to factor here.
How to use GCD & LCM Calculator
- Type two or more whole numbers, separated by commas or spaces.
- Read the GCD and LCM, which update as you type.
- Follow Euclid's steps and the Prime factors table to see how they were found.
- Press Copy on either answer to get the plain number.
Euclid's algorithm on 48 and 18
48, 1848 = 18 × 2 + 12
18 = 12 × 1 + 6
12 = 6 × 2 + 0
GCD 6, LCM 144
48 = 2^4 × 3
18 = 2 × 3^2The last non-zero remainder is the GCD. In the factors, the GCD takes the lowest power of each shared prime (2 × 3) and the LCM takes the highest power of every prime (2^4 × 3^2).
When it helps
- Simplifying a fraction by dividing top and bottom by their GCD.
- Finding a common denominator with the LCM.
- Working out when buses, shifts or machine cycles of different lengths coincide.
- Cutting materials of different lengths into the largest equal pieces.
- Maths homework on factors, multiples and Euclid's algorithm.
Tips for a better result
- A GCD of 1 means your numbers are coprime, so they share no factor. Their LCM is then their product.
- For two numbers, GCD × LCM equals the product of the two, which is a useful way to check your work. It does not hold for three or more.
- Paste a column from a spreadsheet straight into the box, since line breaks count as separators as well.
Good to know
- It takes whole numbers only, with a limit of 50 numbers of up to 40 digits each. Decimals get an explanation.
- Negative numbers are treated by size, so -12 counts as 12. That is the usual convention for GCD and LCM.
- Numbers above 100 trillion are not factored, because that gets slow without much more advanced methods.
- If any number is 0, the LCM is 0. The GCD ignores it, since every number divides 0.
Questions people ask
What is the difference between GCD and LCM?
The GCD is the largest number dividing into all of yours. The LCM is the smallest number that all of yours divide into. For 12 and 18, the GCD is 6 and the LCM is 36.
Are GCD, GCF and HCF the same?
Yes. Greatest common divisor, greatest common factor and highest common factor are three names for one value. Which name you see depends mainly on the country and the textbook.
How does Euclid's algorithm work?
Replace the larger number with the remainder after dividing it by the smaller, and repeat. When the remainder hits zero, the last non-zero value is the GCD. It works quickly even for very large numbers.
Can I enter more than two numbers?
Yes, up to 50. The tool runs the steps through the list one number at a time, and the steps show each pair.
What to use next
- Fraction Calculator: to apply the GCD and common denominators to actual fractions
- Scientific Calculator: for other arithmetic on the numbers you are working with
- Number Base Converter: if the same numbers need to be written in binary or hexadecimal
Last reviewed . Read our editorial policy.