GCD and LCM Calculator
Type two or more whole numbers separated by commas or spaces. You get the greatest common divisor (GCD), the least common multiple (LCM), the prime factorisation of each number and the steps of Euclid's algorithm.
- Updated:
- Free, no sign-up
- Runs in your browser
The greatest common divisor (also called greatest common factor, GCF or HCF) is the largest number that divides all the given numbers exactly. For 12, 18 and 30 it is 6. It is used to simplify fractions, to split things into equal groups without leftovers and to tile a surface with the largest possible square.
The least common multiple is the smallest positive number that is a multiple of all of them. For 12, 18 and 30 it is 180. You need it to add fractions with different denominators, or to know when repeating events coincide again — for example two buses that leave every 12 and 18 minutes meet again after 36 minutes.
Both values can be read from the prime factorisation: the GCD takes the common primes with their lowest exponent, the LCM takes every prime with its highest exponent. 12 = 2² × 3 and 18 = 2 × 3², so GCD = 2 × 3 = 6 and LCM = 2² × 3² = 36. For two numbers there is also a handy identity: GCD × LCM = a × b.
Euclid's algorithm finds the GCD quickly by repeated division: divide the larger number by the smaller and replace the pair with the divisor and the remainder until the remainder is zero. The last non-zero remainder is the GCD. Numbers whose GCD is 1 are called coprime.
How to use it
- Type the numbers separated by commas, spaces or semicolons (between 2 and 20 positive whole numbers).
- The GCD and the LCM are calculated instantly as you type.
- Check the prime factorisation of each number to see where the result comes from.
- Follow Euclid's algorithm for the first two numbers, step by step.
Frequently asked questions
How do you find the GCD of two numbers?
Use Euclid's algorithm: 48 and 18 → 48 = 2 × 18 + 12, 18 = 1 × 12 + 6, 12 = 2 × 6 + 0. The GCD is 6.
How do you calculate the LCM?
Multiply the numbers and divide by their GCD (for two numbers): LCM(12, 18) = 12 × 18 ÷ 6 = 36. For more numbers, apply it pairwise.
What is the GCD used for?
Simplifying fractions (18/24 → divide by 6 → 3/4), making equal groups and solving problems of the type 'largest piece that fits exactly'.
What does coprime mean?
Two numbers are coprime when their only common divisor is 1, for example 8 and 15. Their LCM is simply their product.
Privacy first: this tool runs entirely in your browser. Nothing you type or upload is sent to our servers.