Calculator · Level 1

LCM and GCF calculator with prime factorization and Euclid’s algorithm

Enter two or more whole numbers and get their greatest common factor and least common multiple at once. The steps show the prime factorization of every number, the Euclidean algorithm and, if you like, the full list of factors.

Also available in: Deutsch · Español · Português

Free for teaching and learning (terms (in German)). Ad-free in class: Classroom view · Do you teach?

How to use the calculator

Type two or more whole numbers, separated by commas, semicolons or spaces: 84, 126, 210. The answer shows the greatest common factor (GCF) and the least common multiple (LCM) of all the numbers. The GCF is also called the greatest common divisor (GCD) or, in British schools, the highest common factor (HCF).

One rule keeps large numbers apart from lists: a comma directly in front of exactly three digits is a thousands separator. So 1,000 is one number, while 12,18 and 12, 18 are two numbers. To enter 100 and 200, type 100, 200 with a space or 100; 200.

Under “More options” you can show the Euclidean algorithm for the first two numbers, the extended Euclidean algorithm and the list of all factors of each number up to 10,000.

GCF and LCM from the prime factorization

The calculator first breaks every number into prime factors. Then:

  • the GCF uses only the primes that appear in every number, each with its smallest exponent;
  • the LCM uses every prime that appears anywhere, each with its largest exponent.

The Euclidean algorithm

For large numbers the prime factors are hard to find by hand, but the Euclidean algorithm is fast: divide the larger number by the smaller one, then divide the smaller number by the remainder, and repeat until the remainder is 0. The last divisor is the GCF.

For two numbers, the GCF and the LCM are linked: GCF × LCM = a × b. For 12 and 18: 6 × 36 = 216 = 12 × 18. So once you know the GCF, LCM = a × b ÷ GCF. This shortcut works only for two numbers, not for three or more.

GCF and LCM in word problems

A quick way to decide: if you are splitting things into equal groups that are as large as possible, you need the GCF. If you are looking for the first time two repeating things line up, you need the LCM.

In fractions the least common denominator is the LCM of the denominators, and you simplify a fraction by dividing by the GCF. The fraction calculator does both automatically.

Frequently asked questions

What is the difference between the GCF and the LCM?

The GCF is the largest number that divides all the numbers: GCF(12, 18) = 6. The LCM is the smallest number that all the numbers divide into: LCM(12, 18) = 36. The GCF is never larger than the smallest number, and the LCM is never smaller than the largest number.

What if the numbers have no common factor?

Then the GCF is 1 and the numbers are called relatively prime (or coprime). For two such numbers the LCM is their product: 17 and 31 have GCF 1 and LCM 527.

Can I enter three or more numbers?

Yes, as many as you like. The GCF and LCM are computed for all of them. The Euclidean algorithm and the check GCF × LCM = a × b refer to the first two numbers.

Why is 1,000 read as one number?

Because a comma right before exactly three digits is a thousands separator in American notation. If you mean the two numbers 100 and 200, separate them with a space or a semicolon.

What is the extended Euclidean algorithm?

It writes the GCF as a combination of the two numbers. For 84 and 126: 42 = (−1) × 84 + 1 × 126. Such combinations are used in number theory, for example to solve equations in whole numbers.

Keep learning

Spotted a mistake or have a request? Send us a short message and we will take care of it.

Spotted a mistake or have a request?

Your message about the page “LCM and GCF calculator”. We send the page address along automatically.

Please do not include any other personal data. More in our privacy policy (in German).