CalSolve

GCD and LCM Calculator

Find the greatest common divisor (GCD) and the least common multiple (LCM) of 2 to 10 whole numbers, with Euclid's algorithm step by step.

Greatest common divisor (GCD)

12

Least common multiple (LCM)

720

Prime factorizations

48
2⁴ × 3
36
2² × 3²
60
2² × 3 × 5

Steps

  1. 1Apply Euclid's algorithm to 48 and 36:
  2. 248 = 1 × 36 + 12
  3. 336 = 3 × 12 + 0
  4. 4The last nonzero remainder is the GCD: 12
  5. 5LCM = product ÷ GCD: 48 × 36 ÷ 12 = 144
  6. 6Apply Euclid's algorithm to 12 and 60:
  7. 760 = 5 × 12 + 0
  8. 8The last nonzero remainder is the GCD: 12
  9. 9LCM = product ÷ GCD: 144 × 60 ÷ 12 = 720

About this tool

The greatest common divisor of several numbers is the largest number that divides all of them; the least common multiple is the smallest number that all of them divide. For 48, 36 and 60, the GCD is 12 and the LCM is 720. The GCD is also called the greatest common factor (GCF) or highest common factor (HCF).

The calculator uses Euclid's algorithm, which stays fast even for very large numbers: divide the larger number by the smaller one, then replace the pair with the smaller number and the remainder, until the remainder is 0. For 84 and 36: 84 = 2 × 36 + 12, then 36 = 3 × 12 + 0, so the GCD is 12. The LCM follows from LCM(a, b) = a × b ÷ GCD(a, b) = 84 × 36 ÷ 12 = 252. With more than two numbers, the calculation is repeated pair by pair.

The prime factorizations, also shown, offer another view: the GCD keeps the common prime factors with their smallest exponents, and the LCM keeps every prime factor with its largest exponent. With 48 = 2⁴ × 3, 36 = 2² × 3² and 60 = 2² × 3 × 5, the GCD is 2² × 3 = 12 and the LCM is 2⁴ × 3² × 5 = 720.

Worked example

  1. 1Enter 2 to 10 whole numbers, separated by commas or spaces.
  2. 2Read the GCD and the LCM, and see whether the numbers are coprime.
  3. 3Check the prime factorizations and the steps of Euclid's algorithm. Example: GCD(48, 36, 60) = 12 and LCM(48, 36, 60) = 720.

Formula

a = q × b + r, then GCD(a, b) = GCD(b, r), until r = 0 ; LCM(a, b) = a × b ÷ GCD(a, b)

Related tools

Frequently asked questions

What is the GCD used for?
To simplify fractions (18/24 = 3/4 after dividing by the GCD, 6) and to split things into the largest possible equal parts: a 48 cm × 36 cm board can be cut into square tiles of 12 cm, the GCD, with no waste.
What is the LCM used for?
To add fractions with different denominators, and to find when repeating events coincide: if one bus leaves every 12 minutes and another every 18 minutes, they leave together every 36 minutes, the LCM of 12 and 18.
What does coprime mean?
Two numbers are coprime when their GCD is 1, meaning they have no common divisor other than 1, like 15 and 28. Their LCM is then simply their product: 15 × 28 = 420. Coprime numbers don't have to be prime themselves.
Is there a link between the GCD and the LCM?
Yes: for two numbers, GCD × LCM = the product of the numbers. For 12 and 18, 6 × 36 = 216 = 12 × 18. This relationship doesn't hold for three numbers or more.