Skip to main content
Number theory100% FreeInstant

GCD and LCM Calculator: Greatest Common Divisor and Multiple

This free GCD and LCM calculator finds the greatest common divisor (also called HCF) and the least common multiple of two or more whole numbers. It also shows each number broken into primes.

By Debmedia Technologies LLP · Kolkata, India · Updated

What Is It and When Do You Need It?

The GCD is the biggest number that divides all of your numbers, and the LCM is the smallest number that all of them divide into. You need the GCD to simplify fractions and the LCM to add fractions or to find when repeating events line up.

Enter two or more whole numbers and the tool returns both, plus the prime factors of each number so you can check the result by hand.

How to Use This Tool

  1. Type two or more whole numbers separated by commas, spaces or lines.
  2. Press Calculate.
  3. Read the GCD and LCM at the top.
  4. Look at the prime factors to see why the answers are what they are.

How the Calculation Works

The GCD uses the Euclidean algorithm: replace the pair (a, b) with (b, a mod b) until the second number is zero, and the first number is the GCD. For a list, the tool applies this one number at a time.

The LCM of two numbers is a × b ÷ GCD(a, b). For a list, it takes the LCM of the running result and the next number, using exact big-integer arithmetic.

Worked Example

For 12, 18 and 30: 12 = 2² × 3, 18 = 2 × 3² and 30 = 2 × 3 × 5. The GCD takes the lowest power of each shared prime, which is 2 × 3 = 6. The LCM takes the highest power of every prime, which is 2² × 3² × 5 = 180.

Common Uses

  • Reducing a fraction to lowest terms.
  • Finding a common denominator.
  • Scheduling: buses every 12 and 18 minutes meet again after 36 minutes.
  • Dividing items into equal groups with nothing left over.

Tips and Common Mistakes

  • Only whole numbers are accepted. Zero is ignored for the LCM.
  • If the GCD is 1, the numbers are called coprime.
  • The GCD of any number and 1 is always 1.

Next, you may need the fraction calculator, prime number checker, ratio calculator, permutation and combination calculator.

Everything runs in your browser. Nothing you type is uploaded, stored or sent to any outside service.

Frequently Asked Questions

The greatest common divisor, also called the highest common factor (HCF), is the largest whole number that divides every number in your list without a remainder.
The least common multiple is the smallest positive number that every number in your list divides into evenly.
For two numbers, GCD × LCM equals the product of the numbers. So LCM(a, b) = a × b ÷ GCD(a, b).
Up to about nine quadrillion for the GCD. The LCM uses big integers, so it stays exact even when it is very large.

Disclaimer: results are calculated in your browser from the numbers you enter. Check important results before you rely on them for money, health, safety or legal decisions.