Enter two, three or a dozen numbers and this calculator returns the greatest common divisor and least common multiple together, rather than making you run two separate tools. It shows the prime factorisation of each input, the Euclidean algorithm working for the first pair, every common divisor the numbers share, and whether they are coprime. Useful for reducing fractions, finding common denominators and scheduling problems — see the fraction calculator for fraction arithmetic that uses both, or the ratio calculator for simplifying ratios.
GCD & LCM Calculator
GCD and LCM for as many numbers as you like — with the prime factorisation and Euclidean working shown.
Enter two or more positive whole numbers. Decimals and negatives are ignored — GCD and LCM are defined for integers.
Try one
Greatest common divisor
All common divisors
Prime factorisation
Euclidean algorithm
GCD and LCM, defined
The greatest common divisor (GCD, also called highest common factor or HCF) is the largest whole number that divides every one of your numbers exactly, leaving no remainder. The least common multiple (LCM) is the smallest whole number that every one of your numbers divides into exactly. For 12 and 18: the GCD is 6, and the LCM is 36.
The prime factorisation method
Break each number into its prime factors, then compare. For the GCD, take each prime that appears in every number, raised to the lowest power it appears at. For the LCM, take every prime that appears in any number, raised to the highest power. With 48 = 2⁴ × 3 and 60 = 2² × 3 × 5: the GCD takes 2² × 3 = 12, and the LCM takes 2⁴ × 3 × 5 = 240.
The Euclidean algorithm
For two numbers there is a much faster route that needs no factorisation. Divide the larger by the smaller and keep the remainder; then divide the previous divisor by that remainder; repeat until the remainder is zero. The last non-zero remainder is the GCD. For 48 and 60: 60 = 1×48 + 12, then 48 = 4×12 + 0, so the GCD is 12. This is the method the calculator uses internally, and it is fast enough for very large numbers where factorisation would be impractical.
The relationship between them
For any two numbers, GCD × LCM = the product of the numbers. So once you know one, the other follows: LCM(a,b) = (a × b) ÷ GCD(a,b). This shortcut only works for exactly two numbers — with three or more you have to chain the operation pairwise, which is what this calculator does.
Coprime numbers
Two numbers are coprime (or relatively prime) when their GCD is 1 — they share no factor other than 1. They need not be prime themselves: 8 and 9 are coprime even though neither is prime. Coprimality matters in fraction arithmetic, modular arithmetic and cryptography.
What you actually use it for
The GCD reduces fractions to lowest terms — divide numerator and denominator by their GCD and you are done in one step. The LCM finds common denominators for adding fractions, and answers scheduling questions like "two buses leave every 12 and 18 minutes, when do they next leave together?" (answer: the LCM, 36 minutes). Our fraction calculator applies both automatically.