b2KIT

LCM & GCD Calculator

Calculate the Least Common Multiple and Greatest Common Divisor of two or more numbers with step-by-step factorization.

Tested tool guide Tested browser tools Checked August 16, 2026

What LCM & GCD Calculator does, with a checked example

Enter two or more integers to calculate both their Greatest Common Divisor and Least Common Multiple. The accompanying prime factorizations show which factors contribute to each result: the GCD uses shared primes at their smallest exponents, while the LCM uses every represented prime at its largest exponent. A common mistake is to treat the LCM as the product of the inputs. That works for two positive integers only when their GCD is 1.

Worked example

A concrete input and expected output from the current implementation.

Input

12, 18

Expected output

GCD: 6; LCM: 36. Prime factorizations: 12 = 2^2 x 3; 18 = 2 x 3^2.

The shared primes use the smaller exponents, giving 2 x 3 = 6. Using the larger exponent of each prime gives 2^2 x 3^2 = 36.

How the result is produced

1

Comparing prime exponents

For positive integer entries, each number is expressed as a product of primes. The GCD retains only primes appearing in every input and selects the smallest exponent found for each. The LCM retains every prime appearing anywhere in the input and selects its largest exponent. Multiplying the selected prime powers produces the two results.

2

Handling several numbers

With three or more entries, the exponent comparison covers the entire list. A prime is part of the GCD only if every number contains it. A prime is part of the LCM if at least one number contains it. The resulting GCD divides every entry, while every entry divides the resulting LCM.

Good uses

  • Find when repeating cycles of different integer lengths next coincide, such as events occurring every 12 and 18 minutes.
  • Determine the largest equal group size that divides several item counts without leaving a remainder.
  • Check number-theory exercises by comparing a claimed GCD or LCM with the displayed prime-factor reasoning.

Limits and checks

  • Use whole numbers. Fractions and decimals do not have an ordinary integer GCD or LCM unless they are first converted under a clearly chosen scaling convention.
  • Zero has no prime factorization, and negative entries require a sign convention. Positive integers give the clearest interpretation of the factorization steps.
  • For three or more numbers, do not generalize GCD(a,b) x LCM(a,b) = |a x b| by multiplying every input. That identity is specifically a two-integer relationship.

Common questions

Can the calculator find one GCD and LCM for more than two numbers?

Yes. It calculates a single GCD and a single LCM for the complete set of entered integers. In the factorization, the GCD keeps primes shared by every entry at their smallest exponents. The LCM keeps every prime found in the set at its largest exponent.

Is the LCM always the product of the numbers?

No. Shared prime factors are included only at the greatest exponent required, rather than duplicated from every input. For 12 and 18, the product is 216 but the LCM is 36. For two positive integers, the LCM equals their product only when their GCD is 1.

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