Skip to content

Math

GCD and LCM Calculator

Enter two whole numbers. The calculator returns the greatest common divisor (GCD), the least common multiple (LCM), and a check that GCD x LCM equals the product of the two numbers. It uses the Euclidean algorithm, which is fast even for large inputs. Results apply to positive whole numbers only.

Updated 2026-11-12 Editorial estimate Calccc Editorial Team Free · No sign-up

Loading calculator…

What this calculator does

Two whole numbers share factors and multiples, and the largest shared factor and smallest shared multiple are useful in fractions, scheduling, and ratio problems. This calculator finds both with the Euclidean algorithm, then shows the product check: for any two positive whole numbers, GCD x LCM equals the product. That identity is a quick way to catch an error. Fractions reduce with the GCD, and denominators combine with the LCM.

How to use it

  1. Enter the first whole number.
  2. Enter the second whole number.
  3. Read the greatest common divisor.
  4. Read the least common multiple.
  5. Check that GCD x LCM equals the product.

How it works

Euclidean algorithm: divide a by b, replace (a, b) with (b, remainder), and repeat until the remainder is 0. The last nonzero remainder is the GCD. LCM = a / GCD x b. Product check: GCD x LCM = a x b. For 12 and 18, the GCD is 6, the LCM is 36, and 6 x 36 = 216 = 12 x 18.

Example calculations

Example 1: 12 and 18

The largest shared divisor is 6, and the smallest shared multiple is 36. The check is 6 x 36 = 216, which equals 12 x 18.

Example 2: 24 and 36

The GCD is 12, so 12 divides both evenly. The LCM is 24 / 12 x 36 = 72. The check is 12 x 72 = 864, equal to 24 x 36.

Example 3: 7 and 13

Both are prime and share no factor except 1, so the GCD is 1 and the numbers are coprime. The LCM is 7 x 13 = 91, and the check is 1 x 91 = 91.

What the result means

The GCD answers how numbers can be split into equal groups, which is why it reduces fractions: divide the numerator and denominator by their GCD. The LCM answers when two repeating events line up, and it is the common denominator when adding fractions. The identity GCD x LCM = a x b holds for every pair of positive whole numbers, so it is a fast self-check: if the answers do not multiply to the product, one is wrong. The identity also explains why the LCM is the product when the numbers are coprime. Zero is excluded because every number divides zero.

Common mistakes

  • Swapping the GCD and the LCM in the results.
  • Assuming the LCM is always a x b, which is true only when the GCD is 1.
  • Reducing a fraction with the LCM instead of the GCD.
  • Entering decimals or negative numbers.
  • Stopping the Euclidean algorithm before the remainder reaches zero.

Assumptions and limits

  • Both inputs are positive whole numbers.
  • The numbers are small enough to display exactly.
  • Standard definitions of GCD and LCM are used.
  • Zero and negative values are out of scope.
  • The product check uses ordinary multiplication.

Frequently asked questions

What is the difference between GCD and LCM?

The GCD is the largest number that divides both inputs evenly. The LCM is the smallest number both inputs divide evenly. For 12 and 18, they are 6 and 36.

What does coprime mean?

Two numbers are coprime when their only shared factor is 1, so their GCD is 1. 7 and 13 are coprime, and their LCM is their product, 91.

Why does GCD x LCM equal the product?

Write both numbers as the GCD times coprime partners. The LCM is the GCD times those partners, so the results multiply back to the original product.

How does the Euclidean algorithm work?

Divide the larger number by the smaller and keep the remainder, then repeat with the smaller number and the remainder. The last nonzero remainder is the GCD.

Can I find the GCD or LCM of more than two numbers?

This page takes two at a time. For a list, repeat the process pairwise: the GCD of a running result, and the same for the LCM.

Why use the LCM for fractions?

The LCM of the denominators is the smallest common denominator, so adding or subtracting fractions needs the fewest conversions.

Sources

This calculator is an educational math tool for positive whole numbers. Results are exact for the values entered, but the page does not handle zero, negative numbers, or decimals. Check the product identity and your inputs before relying on the output.

2026 update

How to use the professional output

This page is not just a formula box. The result is designed to be checked, compared, and taken away.

  • Professional worksheet. The result includes the inputs used, the method and scope, and a one-variable sensitivity check for finance calculators.
  • A/B scenarios. Save two input sets in the browser and compare the primary, secondary, and breakdown figures side by side.
  • Print / PDF and CSV. Print a branded worksheet, or export the year-by-year table when the calculator produces one.

The formulas and assumptions above still govern the number. The worksheet makes the estimate auditable; it does not make it a lender quote, tax return, or personalized advice.

Go deeper

Guides that explain the math

GCD and LCM: Prime Factors, Euclidean Algorithm, and Word Problems
Math

GCD and LCM: Prime Factors, Euclidean Algorithm, and Word Problems

Prime factors and the Euclidean algorithm find the GCD and LCM quickly. Worked examples for fractions, schedules, tiles, and remainder word problems.

7 min read

Calccc Editorial Team · Updated 2026-11-12

Prepared by Calccc Editorial Team as an educational estimate. This page is not a licensed professional review and is not financial, medical, legal, or tax advice.

Editorial estimate prepared by the Calccc Editorial Team; not a licensed professional review.