GCD and LCM Calculator

Type two or more whole numbers. You get the greatest common divisor and the least common multiple, and for two numbers, every step of Euclid's algorithm.

How it works

The greatest common divisor, or GCD, is the largest whole number that divides every number in the list. It is also called the highest common factor (HCF) or greatest common factor (GCF).

The least common multiple, or LCM, is the smallest positive whole number that every number in the list divides. It is worked out pair by pair as a × b ÷ GCD(a, b).

Both use Euclid's algorithm and exact whole-number arithmetic, so large numbers keep every digit. Everything runs on this page.

How to use it

  1. 1 Type two or more whole numbers, separated by commas, spaces or new lines.
  2. 2 Read the GCD and the LCM.
  3. 3 For exactly two numbers, read Euclid's algorithm step by step below.
  4. 4 Press Copy beside a result to copy it.

Good to know

  • To simplify a fraction, divide the top and the bottom by their GCD. 18/48 has a GCD of 6, so it becomes 3/8.
  • To add fractions, use the LCM of the denominators as the common denominator.
  • For two numbers, GCD × LCM equals the product of the two numbers. 6 × 144 = 18 × 48.
  • Numbers whose GCD is 1 are called coprime. The calculator says so when they are.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

Greatest common divisor and least common multiple, worked by hand

The greatest common divisor of two whole numbers is the largest number that divides both of them evenly. For 48 and 18 it is 6. The least common multiple is the smallest positive number that both of them divide. For 48 and 18 it is 144. The two are linked: for any two numbers, the GCD times the LCM equals the two numbers multiplied together. Here, 6 × 144 and 48 × 18 are both 864.

The fastest way to find a GCD by hand is Euclid's algorithm, which is over 2,000 years old. Divide the larger number by the smaller and keep the remainder. Then divide the smaller number by that remainder, and repeat until the remainder is 0. The last number you divided by is the GCD. For 48 and 18: 48 = 18 × 2 + 12, then 18 = 12 × 1 + 6, then 12 = 6 × 2 + 0. The last divisor is 6. When you enter exactly two numbers, the calculator lists these steps so you can follow them or copy them into homework.

For a list of more than two numbers, the GCD and LCM are worked out one pair at a time. The GCD of 12, 18 and 30 is the GCD of 6 and 30, which is 6. The LCM is the LCM of 36 and 30, which is 180. Every step uses exact whole-number arithmetic, so the LCM of a long list stays exact even when it grows large. The LCM of the numbers from 1 to 30 is 2,329,089,562,800, and every digit shown is correct.

These two numbers do everyday jobs. The GCD simplifies fractions and ratios: 18/48 divided top and bottom by 6 is 3/8. It also gives the largest square tile that fits a floor exactly, or the largest equal groups a set can be split into. The LCM finds when repeating things line up again. A bus every 12 minutes and a train every 18 minutes leave together every 36 minutes. It is also the common denominator for adding fractions.

Some limits are worth knowing. The calculator takes whole numbers only, not decimals or fractions. Signs are ignored. A list with a 0 has an LCM of 0, and a list of only zeros has no GCD. The input can be up to 10,000 characters long, which is room for over a thousand ordinary numbers, and keeps every calculation fast. Euclid's steps are shown for a pair of numbers only, and only when there are 30 steps or fewer.

Frequently asked questions

Are GCD, HCF and GCF the same thing?

Yes. Greatest common divisor, highest common factor and greatest common factor are three names for the same number. Which one you meet depends on the country and the textbook.

What is the GCD and LCM of 12, 18 and 30?

The GCD is 6, since 6 divides all three and no larger number does. The LCM is 180, the smallest number that 12, 18 and 30 all divide.

How does it handle 0 and negative numbers?

Signs are ignored, so -12 counts as 12. The GCD of 0 and 5 is 5, since every number divides 0. Any list with a 0 in it has an LCM of 0. A list of only zeros has no GCD, and the tool says so.

Are my numbers sent anywhere?

No. The calculation runs in this page, and nothing is sent to YappyKit or anyone else.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.