GCF and LCM Calculator

The GCF and LCM calculator only needs the numbers, separated by commas or spaces – two to ten whole numbers. You get the GCF (GCD), the LCM and both methods step by step.

Source: Wolfram MathWorld – Greatest common divisor. Updated: .

whole numbers up to 10¹², separated by commas, semicolons or spaces
My ToolboxYour inputs are saved in this browser only.

Result

Greatest common factor (GCF / GCD)
GCF(12, 18, 30) = 6
Least common multiple (LCM)
LCM(12, 18, 30) = 180
Prime factorization
  • 12 = 2² · 3
  • 18 = 2 · 3²
  • 30 = 2 · 3 · 5
Prime factor method
  • GCF = common prime factors with the smallest exponent: 2 · 3 = 6
  • LCM = every prime factor with the largest exponent: 2² · 3² · 5 = 180
Euclidean algorithm
  • GCF(12, 18):
  • 18 = 1 · 12 + 6
  • 12 = 2 · 6 + 0
  • GCF(6, 30):
  • 30 = 5 · 6 + 0
All common factors
1, 2, 3, 6

How it is calculated

The greatest common factor (GCF, also GCD or HCF) is the largest number that divides all the given numbers exactly; the least common multiple (LCM) is the smallest number that is a multiple of all of them. For 12 and 18, GCF = 6 and LCM = 36. For two numbers they are linked: GCF × LCM = a × b.

GCF and LCM with prime factorization

Write each number as a product of primes: 12 = 2² × 3, 18 = 2 × 3², 30 = 2 × 3 × 5. For the GCF, take only the primes that appear in every number, each with its smallest exponent: 2 × 3 = 6. For the LCM, take every prime with its largest exponent: 2² × 3² × 5 = 180.

GCF with the Euclidean algorithm

Faster for large numbers: divide the larger number by the smaller, then the divisor by the remainder, and repeat until the remainder is 0. The last divisor is the GCF. Example: 1071 = 2 × 462 + 147, 462 = 3 × 147 + 21, 147 = 7 × 21 + 0 → GCF = 21. The method goes back to Euclid’s Elements, Book VII.

What are GCF and LCM used for?

Keep going with fractions in the fraction calculator, convert decimals with the decimal to fraction calculator, or use the calculator for anything else.

Frequently asked questions

How do you find the GCF?

Either factor both numbers into primes and multiply the shared factors (12 = 2² × 3, 18 = 2 × 3² → 2 × 3 = 6), or use the Euclidean algorithm and keep dividing by the remainder.

How do you find the LCM?

Multiply every prime factor using its highest exponent: LCM(12, 18) = 2² × 3² = 36. For two numbers you can also use LCM = a × b ÷ GCF = 12 × 18 ÷ 6 = 36.

How do I find the GCF and LCM of three numbers?

Step by step: first the first two, then combine with the third. GCF(12, 18, 30) = GCF(6, 30) = 6 and LCM(12, 18, 30) = LCM(36, 30) = 180.

What does relatively prime mean?

Two numbers are relatively prime (coprime) when their GCF is 1, like 8 and 15. Their LCM is then simply the product: 8 × 15 = 120.

Is GCF the same as GCD and HCF?

Yes – greatest common factor, greatest common divisor and highest common factor are three names for the same number.

Sources and legal basis

As of:

Related tools