Math

GCD and LCM Calculator

Find the greatest common divisor and least common multiple of two whole numbers.

Exact method explained belowEditable inputs

Set up your calculation

Runs on your device

SOLUTION

Your result

Let’s calculate.

Use the Calculate button to see your result.

Review the method below for assumptions and conventions.

How to use this tool

  1. Enter first number, second number.
  2. Select Calculate to view the result.
  3. Check the method and assumptions below before using the result.

The method, explained

The Euclidean algorithm repeatedly replaces (a, b) with (b, a mod b) until the remainder is zero. LCM = a ÷ GCD × b. Integer arithmetic keeps both results exact.

A WORKED EXAMPLE

For 18 and 24, the greatest common divisor is 6 and the least common multiple is 72.

What to keep in mind

Inputs must be nonnegative whole numbers. At least one must be positive. For a positive number paired with zero, the GCD is the positive number and the LCM is zero.

Common questions

Is GCD the same as HCF?

Yes. Highest common factor and greatest common divisor refer to the same positive common factor.

How does LCM help with fractions?

The least common multiple of denominators gives the smallest shared denominator for combining fractions.

Methodology maintained by ClarityKit. How these tools are built and checked.