GCD & LCM Calculator

Find the greatest common divisor and the least common multiple of two integers. The Euclidean algorithm is shown one division at a time, and because everything runs on big integers, numbers of any size work.
Computed
The gcd, the lcm and the full working are shown below.
Greatest common divisorexact

21

Least common multipleexact

1260

Step-by-step solution

  1. 1

    Start

    Find gcd(252, 105) with the Euclidean algorithm: divide, keep the remainder, repeat until the remainder is 0.

    gcd⁡(252, 105)\gcd(252,\, 105)
  2. 2

    Division step 1

    Divide 252 by 105 and keep the remainder 42 — it becomes the next divisor.

    252=2⋅105+42252 = 2 \cdot 105 + 42
  3. 3

    Division step 2

    Divide 105 by 42 and keep the remainder 21 — it becomes the next divisor.

    105=2⋅42+21105 = 2 \cdot 42 + 21
  4. 4

    Division step 3

    21 divides 42 exactly, so the algorithm stops here.

    42=2⋅21+042 = 2 \cdot 21 + 0
  5. 5

    The gcd is the last non-zero remainder

    The remainders shrink until they hit 0; the last divisor, 21, is the gcd.

    gcd⁡(252, 105)=21\gcd(252,\, 105) = 21
  6. 6

    From the gcd to the lcm

    For any two numbers, gcd · lcm = abs(a · b). Dividing 252 · 105 by the gcd 21 gives the lcm.

    lcm⁡(252, 105)=252⋅105gcd⁡(252, 105)=2646021=1260\operatorname{lcm}(252,\, 105) = \frac{252 \cdot 105}{\gcd(252,\, 105)} = \frac{26460}{21} = 1260
  7. 7

    Result

    gcd(252, 105) = 21 and lcm(252, 105) = 1260