Skip to content
HNarzędzia
en
Categories

GCD and LCM calculator - greatest common divisor and least common multiple

Enter two or more integers - the calculator finds the greatest common divisor (GCD) and least common multiple (LCM), factorises each number into primes and shows the steps of the Euclidean algorithm.

  • Free
  • No sign-up
  • Private
  • Runs locally

At least two numbers separated by spaces, commas or semicolons, e.g. 48 180 or 24, 36, 60. Very large numbers are supported.

Result

GCD (greatest common divisor)
12
LCM (least common multiple)
720
Coprime numbers
no

Prime factorisation

NumberFactorisation
482⁴ · 3
1802² · 3² · 5

The GCD is the product of common factors with the lowest powers, the LCM - of all factors with the highest powers:

GCD = 2² · 3 = 12

LCM = 2⁴ · 3² · 5 = 720

Euclidean algorithm step by step

GCD(48, 180)
  1. 180 = 3 · 48 + 36
  2. 48 = 1 · 36 + 12
  3. 36 = 3 · 12 + 0

The last non-zero remainder is the GCD = 12.

LCM(48, 180) = 48 · 180 / GCD = 48 · 180 / 12 = 720.

Applications

  • Simplifying 48/180: divide the numerator and denominator by the GCD = 12, so 48/180 = 4/15.
  • The common denominator of 1/48 and 1/180 is the LCM = 720.
Fraction calculator →

How to find the GCD and LCM

  1. 1.

    Enter numbers

    Type at least two integers separated by spaces, commas or semicolons, e.g. 48 180 or 24, 36, 60.

  2. 2.

    Read the GCD and LCM

    Results appear instantly, with a note whether the numbers are coprime (GCD = 1).

  3. 3.

    Check the factorisation

    See each number written as a product of prime powers, e.g. 180 = 2² · 3² · 5.

  4. 4.

    Follow the algorithm

    The Euclidean algorithm lists each division with remainder for every pair of numbers.

The Euclidean algorithm

Divide the larger number by the smaller one with remainder, then divide the previous divisor by the remainder, and repeat until the remainder is 0. The last non-zero remainder is the GCD. For 48 and 180:

  • 180 = 3 · 48 + 36
  • 48 = 1 · 36 + 12
  • 36 = 3 · 12 + 0 → GCD = 12

The method needs only a handful of steps even for numbers with dozens of digits, which is why the calculator can handle integers up to 200 digits exactly. With three or more numbers it works pairwise: GCD(24, 36, 60) = GCD(GCD(24, 36), 60) = GCD(12, 60) = 12, and each pair gets its own step-by-step table (the first 40 steps are shown).

GCD and LCM from prime factors

Write each number as a product of primes: 48 = 2⁴ · 3 and 180 = 2² · 3² · 5.

  • GCD - take the primes common to all numbers with the lowest power: 2² · 3 = 12.
  • LCM - take every prime that appears with the highest power: 2⁴ · 3² · 5 = 720.

For exactly two numbers there is a shortcut: GCD · LCM = a · b, so LCM = 48 · 180 / 12 = 720. This identity does not hold for three or more numbers - use the factor method or compute pairwise. Numbers up to 30 digits are factorised (trial division plus Pollard’s rho); for longer numbers the factorisation is skipped, but GCD and LCM are still exact.

GCD vs LCM: which one do I need?

ProblemUseExample
Simplify a fractionGCD48/180 ÷ 12 = 4/15
Add fractions with different denominatorsLCM1/4 + 1/6 → denominator 12
Cut materials into equal pieces with no wasteGCDboards of 120 cm and 84 cm → pieces of 12 cm
When do repeating events coincide?LCMbuses every 12 and 18 min meet every 36 min
Gear teeth, tiling, schedulingLCMgears with 20 and 30 teeth realign after 60 teeth

For full fraction arithmetic use the fraction calculator.

Common mistakes

  • Mixing up the powers - GCD uses the lowest exponent, LCM the highest. Swapping them is the most frequent error.
  • Forgetting primes that appear only once - the 5 in 180 belongs to the LCM even though 48 has no factor 5.
  • Using a · b / GCD for three numbers - it only works for pairs.
  • Zero and negatives - GCD(a, 0) = |a|, LCM with a zero is 0, and negative inputs are treated as their absolute values.

Frequently asked questions

How do I find the GCD of two numbers?

+
Use the Euclidean algorithm: divide with remainder until the remainder is 0; the last non-zero remainder is the GCD. GCD(48, 180) = 12.

How do I find the LCM?

+
LCM(a, b) = a · b / GCD(a, b). LCM(48, 180) = 8640 / 12 = 720.

What is the GCD of three numbers?

+
Compute it pairwise: GCD(24, 36, 60) = GCD(12, 60) = 12. The LCM works the same way: LCM(4, 6, 10) = LCM(12, 10) = 60.

Is GCD the same as HCF or GCF?

+
Yes. Greatest common divisor (GCD), highest common factor (HCF) and greatest common factor (GCF) are three names for the same number.

What does coprime mean?

+
Two numbers are coprime when their GCD is 1, e.g. 8 and 15. Their LCM is then simply their product (120).

What is the GCD with zero?

+
GCD(a, 0) = |a|. The LCM with zero is 0, and GCD(0, 0) is undefined.

Does it work with large numbers?

+
Yes, numbers can have up to 200 digits and GCD and LCM are exact. Prime factorisation is shown for numbers up to 30 digits.

Updated: