Skip to content

GCD and LCM Calculator

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

GCD and LCM Calculator tool

Loading...

Example

Input: Numbers 24, 36

Result: GCD 12, LCM 72

Euclid: GCD(36, 24) = GCD(24, 12) = GCD(12, 0) = 12, and LCM = 24 x 36 / 12 = 72.

  1. Enter two or more non-zero whole numbers separated by commas or spaces.
  2. View both the GCD (Greatest Common Divisor) and LCM (Least Common Multiple) results instantly.
  3. Check the Coprime result to see whether the numbers share any common factor other than 1.
  4. Confirm the parsed list of numbers shown with the results matches what you meant to enter.
  5. Click the copy button to copy either the GCD or LCM result.

GCD and LCM With Everyday Examples

The greatest common divisor (GCD) is the largest number that divides all your numbers exactly. The least common multiple (LCM) is the smallest number they all divide into. For 24 and 36, the GCD is 12 and the LCM is 72. Enter two or more whole numbers and this calculator finds both. It also tells you whether the numbers are coprime.

The GCD is what you divide by to simplify a fraction. Since the GCD of 24 and 36 is 12, the fraction 24/36 reduces to 2/3 in one step. It also answers layout questions. The largest square tile that fits a 240 cm by 180 cm floor with no cutting is 60 cm, the GCD of the two sides. The LCM is the lowest common denominator when you add fractions. To add 1/4 and 1/6, use 12, the LCM of 4 and 6. It also tells you when repeating events line up. Buses every 12 and 18 minutes leave together again every 36 minutes.

The calculator uses the Euclidean algorithm. It swaps the pair for the smaller number and the remainder, again and again, until the remainder is 0. For more than two numbers, it works through them in pairs. It uses exact whole-number math, so even very long numbers give precise answers.

You can separate numbers with commas, spaces or semicolons. Negative numbers are allowed, and their sign is ignored. Zero is not accepted. Numbers are coprime when their GCD is 1, as with 8 and 15, even though neither is prime. For the prime factors behind these results, try the Prime Number Checker. To go on and add fractions, use the Fraction Calculator.

Formula / How It Works

GCD via Euclidean algorithm: GCD(a, b) = GCD(b, a mod b) until b = 0 | LCM(a, b) = (a x b) / GCD(a, b)

Frequently Asked Questions

The GCD, or greatest common divisor, is the largest whole number that divides both numbers with no remainder. For 12 and 18 it is 6. It is also called the greatest common factor (GCF) or highest common factor (HCF). All three names mean the same thing.
The LCM, or least common multiple, is the smallest positive number that both numbers divide into evenly. For 4 and 6 it is 12, since 12 is the first number in both the 4 times table and the 6 times table. When adding fractions, it is the lowest common denominator.
For two positive numbers, the GCD times the LCM equals the two numbers multiplied together. For 24 and 36: 12 x 72 = 864, and 24 x 36 = 864. So once you know the GCD, the LCM is the product divided by the GCD. This shortcut only works for exactly two numbers.
Divide the larger number by the smaller and keep the remainder. Then repeat with the smaller number and that remainder, until the remainder is 0. The last non-zero remainder is the GCD. For 36 and 24: 36 leaves 12 when divided by 24, then 24 leaves 0 when divided by 12, so the GCD is 12.
Two numbers are coprime when their only common divisor is 1, so their GCD is 1. For example, 8 and 15 are coprime even though neither is prime. Coprime numbers have an LCM equal to their product: the LCM of 8 and 15 is 120. The calculator shows a Coprime result for every set you enter.

Related Tools

Fraction Calculator

Add, subtract, multiply, divide, and simplify fractions with mixed number and decimal results.

Math and Numbers

Prime Number Checker and Generator

Check if a number is prime and generate lists of prime numbers in any range.

Math and Numbers

Modulo Calculator

Calculate the remainder of division (modulo operation) for any two numbers.

Math and Numbers

Percentage Calculator

Calculate percentages, percentage change, difference, increase, and decrease instantly.

Math and Numbers