b2KIT

GCD / LCM Calculator

Calculate the greatest common divisor and least common multiple of two or more numbers with steps.

Tested tool guide Tested browser tools Checked August 16, 2026

What GCD / LCM Calculator does, with a checked example

A single set of two or more positive integers yields both divisibility results: the greatest common divisor shared by every entry and the least common multiple divisible by every entry. The accompanying steps help verify how the inputs lead to each value. With three or more numbers, both answers concern the complete set, not separate pairs. This distinction matters because the overall GCD can be 1 even though some pairs in the set have larger common divisors.

Worked example

A concrete input and expected output from the current implementation.

Input

18, 24, 30

Expected output

GCD = 6
LCM = 360

The prime factorizations are 18 = 2 * 3^2, 24 = 2^3 * 3, and 30 = 2 * 3 * 5. Shared factors at their lowest powers give 2 * 3 = 6, while all factors at their highest powers give 2^3 * 3^2 * 5 = 360.

How the result is produced

1

Finding the shared divisor

For the GCD, the relevant factors are those shared by every entered integer. In a prime-factor view, keep only primes occurring in all entries and use the smallest exponent seen. For 18, 24, and 30, that leaves 2 * 3. The result is the greatest positive integer that divides the entire list without a remainder.

2

Building the least multiple

For the LCM, include every prime occurring in any entry and use the largest exponent required by any one entry. This gives the smallest positive integer divisible by each input. For two nonzero integers, LCM(a,b) * GCD(a,b) = |a * b| provides an independent check on the two reported values.

Good uses

  • Reduce several integer measurements by their largest shared scale factor.
  • Find the least common denominator needed for fractions with different positive integer denominators.
  • Determine when repeating cycles with integer periods will coincide again after starting together.

Limits and checks

  • Enter integers, not decimal approximations. Conventional GCD and LCM questions concern exact integer divisibility, so rounding a decimal can change the problem.
  • If a problem contains zero or negative integers, confirm the accepted input and sign convention instead of assuming it matches a particular textbook or programming language.
  • An LCM synchronizes cycle lengths only when their starting points are aligned. Different starting offsets require an additional congruence calculation and may never coincide.

Common questions

Does a GCD of 1 mean every pair of inputs is coprime?

No. A whole-set GCD of 1 says only that no integer greater than 1 divides every entry. For example, GCD(6, 10, 15) is 1, but the three pairwise GCDs are 2, 3, and 5. If pairwise coprimality matters, calculate or inspect each pair separately.

Can I get the LCM by multiplying all the inputs?

Not generally. The product is a common multiple for positive integers, but it may repeat prime factors that are needed only once. For 12 and 18, the product is 216 while the LCM is 36. The product equals the LCM when the positive inputs are pairwise coprime; otherwise, use the calculated LCM.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools