Skip to main content
CalcChef

LCM and GCD Calculator

GCD (also called GCF or HCF) and LCM of 2 to 10 whole numbers, with the Euclidean steps and the prime factors of each number shown. How it works

Use the LCM and GCD Calculator

Numbers (2 to 10)

Greatest common divisor (GCD)
6
LCM 36
Greatest Common Divisor (GCD)
6
Least Common Multiple (LCM)
36

Identity check

GCD × LCM = 6 × 36 = 216 = |12 × 18| = 216

Euclidean algorithm

  1. 12 = 0 × 18 + 12
  2. 18 = 1 × 12 + 6
  3. 12 = 2 × 6 + 0
  4. → GCD = 6

Prime factorizations

  • 12 = 2^2 × 3
  • 18 = 2 × 3^2

About the LCM and GCD Calculator

The GCD (greatest common divisor, also called the HCF or GCF) is the largest whole number that divides every number in a set. The LCM (least common multiple) is the smallest positive number that each of them divides. For 12 and 18 the GCD is 6 and the LCM is 36.

Methodology

The GCD comes from the Euclidean algorithm. The LCM uses the identity LCM(a, b) = a × b ÷ GCD(a, b). For three or more numbers both are folded in pairs: GCD(a, b, c) = GCD(GCD(a, b), c), and likewise for the LCM. This GCD calculator takes 2 to 10 integers of up to 10^15 in absolute value, works in exact integer arithmetic, and can show the prime factorization of each input up to 10^12.

Frequently asked questions

How do you find the GCD of two numbers?
Divide the larger by the smaller and keep the remainder. Replace the pair with the smaller number and the remainder, and repeat until the remainder is 0. The last non-zero remainder is the GCD. For 48 and 18: 48 = 2 × 18 + 12, 18 = 1 × 12 + 6, 12 = 2 × 6 + 0, so the GCD is 6.
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.
How do you get the LCM from the GCD?
LCM(a, b) = a × b ÷ GCD(a, b). For 12 and 18 that is 216 ÷ 6 = 36. The shortcut is for two numbers; with three or more, take the LCM of the first two, then the LCM of that result and the next number.
How do you find the GCD and LCM by prime factorization?
12 = 2² × 3 and 18 = 2 × 3². The GCD takes the lowest power of each prime the numbers share: 2 × 3 = 6. The LCM takes the highest power of every prime: 2² × 3² = 36.
What does a GCD of 1 mean?
The numbers share no factor other than 1 and are called coprime. 17 and 5 are coprime, so their LCM is their product, 85.
Can I enter zero, negative numbers or decimals?
Zero is rejected. A negative number is treated as its absolute value. Decimals are rejected too, because GCD and LCM are only defined for whole numbers.

Related Tools

View all tools