šŸ”¢GCD & LCM Calculator

Find the greatest common divisor (GCD) and least common multiple (LCM) of any number of integers. Enter numbers separated by commas for unlimited inputs, with prime factorizations and step-by-step explanation.

Prefer to skip the form? Scroll down and Ask AI Instead. Just describe your situation and let AI handle the math for you in seconds.

Enter any amount of positive integers separated by commas.

Separate values with commas — e.g. 12, 18, 24

Advertisement

728 Ɨ 90

✦ Ask AI Instead

GCD Calculator and LCM Calculator: Complete Guide with Steps

Whether you need a GCD calculator to simplify a fraction or an LCM calculator to find a common denominator, understanding the greatest common divisor and least common multiple is essential for arithmetic, algebra, and beyond. This tool computes both values instantly for any number of integers and shows prime factorizations so you can follow every step.

What Is the Greatest Common Divisor (GCD)?

The greatest common divisor, also called the greatest common factor (GCF) or highest common factor (HCF), is the largest positive integer that divides two or more numbers without leaving a remainder. For example, GCD(48, 18) = 6 because 6 is the largest number that fits evenly into both 48 and 18. Every integer that divides both numbers is called a common divisor, and the GCD is simply the greatest one among them.

The GCD is directly tied to divisibility. When GCD(a, b) = d, it means both a and b are multiples of d, and no larger multiple exists that satisfies that condition for both values simultaneously.

What Is the Least Common Multiple (LCM)?

The least common multiple is the smallest positive integer that is a multiple of each number in a set. LCM(4, 6) = 12 because 12 is the first number that both 4 and 6 divide into evenly. The LCM is indispensable any time you need a common denominator to add or subtract fractions, or when you need to synchronize repeating events.

Greatest Common Divisor Calculator with Steps: The Euclidean Algorithm

The Euclidean algorithm is the most efficient method for finding the GCD by hand or by computer. It works by repeatedly replacing the pair (a, b) with (b, a mod b) until the remainder reaches zero. The last nonzero remainder is the GCD.

  • Start with GCD(48, 18).
  • Step 1: 48 = 2 x 18 + 12, so GCD(48, 18) = GCD(18, 12).
  • Step 2: 18 = 1 x 12 + 6, so GCD(18, 12) = GCD(12, 6).
  • Step 3: 12 = 2 x 6 + 0. The remainder is zero, so GCD = 6.

This algorithm converges rapidly. For any two numbers, the number of steps required is at most five times the count of digits in the smaller number, making it extremely practical even for very large integers.

How to Find GCD and LCM Using Prime Factorization

Prime factorization is a second method that works well when you want to see the full structure of the numbers. Break each number into its prime factors, then apply these rules:

  • To find the GCD, take each prime factor that appears in every number and use the lowest exponent seen across all numbers.
  • To find the LCM, take every prime factor that appears in any number and use the highest exponent seen.

Example with 48 and 18: 48 = 2^4 x 3 and 18 = 2 x 3^2. The GCD uses min exponents: 2^1 x 3^1 = 6. The LCM uses max exponents: 2^4 x 3^2 = 16 x 9 = 144. This calculator displays these prime factorizations automatically, so you can verify the logic at a glance.

Least Common Multiple Calculator for Fractions

Adding fractions with different denominators is one of the most common reasons to reach for an LCM calculator. To add 1/4 and 1/6, you need a common denominator. The ideal choice is the LCM(4, 6) = 12 because it is the smallest value that works, keeping numbers manageable.

  • Convert 1/4 to 3/12.
  • Convert 1/6 to 2/12.
  • Add: 3/12 + 2/12 = 5/12.

Using the LCM instead of simply multiplying denominators avoids unnecessarily large numbers and reduces the simplification work afterward. This relationship between LCM and fraction arithmetic is also why the two concepts are always taught together in math curricula.

The GCD-LCM Identity and Coprime Numbers

For any two positive integers a and b, the following identity always holds: GCD(a, b) x LCM(a, b) = a x b. This means once you know the GCD, you can compute the LCM with a single multiplication and division rather than a fresh algorithm. For GCD(48, 18) = 6: LCM = (48 x 18) / 6 = 144.

A special case arises when GCD(a, b) = 1. The two numbers are then called coprime or relatively prime, meaning they share no common factors beyond 1. For example, 8 and 15 are coprime because 8 = 2^3 and 15 = 3 x 5 share no prime factors. Coprime pairs have LCM = a x b. Coprimality is foundational in RSA encryption, the Chinese Remainder Theorem, and reducing fractions to their lowest terms.

Real-World Applications of GCD and LCM

  • Simplifying fractions: To reduce 24/36, compute GCD(24, 36) = 12 and divide both by 12 to get 2/3.
  • Scheduling: If two machines cycle every 8 and 12 minutes respectively, they next sync at LCM(8, 12) = 24 minutes.
  • Music and rhythm: A 3-beat pattern and a 4-beat pattern align every LCM(3, 4) = 12 beats.
  • Computer science: Memory page sizes, hash table capacities, and cryptographic key generation all rely on divisibility and GCD properties.

Frequently Asked Questions

What is the difference between GCD and LCM?

The GCD (greatest common divisor) is the largest number that divides all given numbers evenly. The LCM (least common multiple) is the smallest number that all given numbers divide into evenly. GCD is used to simplify fractions and check divisibility, while LCM is used to find common denominators and synchronize repeating events. They are linked by the identity: GCD(a, b) x LCM(a, b) = a x b.

How do I find the greatest common divisor?

The fastest method is the Euclidean algorithm: repeatedly divide the larger number by the smaller and replace the larger with the remainder, continuing until the remainder is zero. The last nonzero remainder is the GCD. For GCD(56, 98): 98 = 1 x 56 + 42; 56 = 1 x 42 + 14; 42 = 3 x 14 + 0. GCD = 14. Alternatively, factor both numbers into primes and multiply the common prime factors using the smallest exponents.

When do I use LCM in math?

Use the LCM whenever you need a shared multiple of two or more numbers. The most common case is adding or subtracting fractions with different denominators: the least common denominator is the LCM of those denominators. Other uses include finding when repeating events coincide (like two lights flashing at different intervals), solving certain Diophantine equations, and working with modular arithmetic in number theory.

What is the Euclidean algorithm for finding GCD?

The Euclidean algorithm finds the GCD of two integers by repeatedly applying the rule GCD(a, b) = GCD(b, a mod b) until the second number becomes zero. At that point, the first number is the GCD. For GCD(270, 192): 270 mod 192 = 78; 192 mod 78 = 36; 78 mod 36 = 6; 36 mod 6 = 0. GCD = 6. The algorithm is efficient enough to handle very large numbers and is the basis for GCD functions in most programming languages.