GCD and LCM Calculator
Enter two or more positive whole numbers. The calculator will find the greatest common divisor and the least common multiple using exact integer logic.
A GCD and LCM calculator answers two closely related questions about divisibility. The GCD tells you the largest number that divides every entered number evenly. The LCM tells you the smallest positive number that every entered number can divide into evenly.
Those two answers are useful in fractions, ratios, schedules, repeating cycles, modular arithmetic, and number theory. They also connect naturally to prime factorization, because every positive integer can be broken into prime factors.
What GCD Means
The GCD, also called the greatest common divisor or greatest common factor, is the largest positive integer shared by all the numbers.
For example, the divisors of 12 include 1, 2, 3, 4, 6, and 12. The divisors of 18 include 1, 2, 3, 6, 9, and 18. The largest shared divisor is 6, so the GCD of 12 and 18 is 6.
The idea is simple: the GCD measures how much divisibility the numbers have in common. A larger GCD means the numbers share a larger factor. A GCD of 1 means the numbers are coprime, which means they have no shared divisor other than 1.
What LCM Means
The LCM, or least common multiple, is the smallest positive number that is a multiple of all the entered numbers.
For 12 and 18, the common multiples include 36, 72, 108, and so on. The smallest one is 36, so the LCM of 12 and 18 is 36.
The LCM measures when numbers line up again. That is why it appears in fraction denominators, repeating schedules, gear cycles, and timing problems.
How the Calculator Finds the Answer
This calculator first reads the numbers as positive whole numbers. Then it finds the GCD using the Euclidean algorithm, a fast method based on remainders.
The main idea is this: if one number is divided by another, the GCD does not change when the larger number is replaced by the remainder. The process repeats until the remainder becomes 0. The last non-zero number is the GCD.
Example: To find the GCD of 18 and 12, divide 18 by 12. The remainder is 6. Then divide 12 by 6. The remainder is 0. So the GCD is 6.
After the GCD is known, the LCM can be found from the relationship between two positive integers:
LCM(a, b) = |a × b| ÷ GCD(a, b)
For more than two numbers, the same method is applied step by step. For example, the GCD of 12, 18, and 30 is found by comparing 12 and 18 first, then comparing that result with 30.
GCD and LCM Through Prime Factorization
Prime factorization gives another clean way to understand both ideas. Each number can be written as a product of prime numbers. The GCD uses the shared prime factors with the lowest powers. The LCM uses all prime factors with the highest powers.
| Number or Result | Prime Factor Form | What It Shows |
|---|---|---|
| 12 | 2² × 3 | Two 2s and one 3 |
| 18 | 2 × 3² | One 2 and two 3s |
| GCD | 2 × 3 = 6 | Shared primes with the lowest powers |
| LCM | 2² × 3² = 36 | All needed primes with the highest powers |
This is where prime numbers matter. A prime factor is not just a detail; it explains why the GCD and LCM have the values they do. If you need to check whether a factor is prime, use the Prime Number Checker to verify it directly.
When GCD Is More Useful Than LCM
Use the GCD when the problem asks for the largest equal group size, the largest shared divisor, or the simplest form of a ratio.
Reducing Fractions
To reduce 18/24, find the GCD of 18 and 24. The GCD is 6. Divide both parts by 6, and the fraction becomes 3/4.
Splitting Items Evenly
If you have 36 apples and 48 oranges and want identical packs with no leftovers, the GCD gives the largest number of packs you can make. Since GCD(36, 48) = 12, you can make 12 equal packs.
Recognizing Coprime Numbers
If the GCD of two numbers is 1, the numbers are coprime. For example, 17 and 31 are coprime because they share no divisor other than 1. Since both are prime, this result is expected.
When LCM Is More Useful Than GCD
Use the LCM when the problem asks when numbers meet again, repeat together, or need a shared denominator.
Finding a Common Denominator
To add fractions like 1/6 and 1/8, the LCM of 6 and 8 gives the smallest shared denominator. Since LCM(6, 8) = 24, the fractions can be rewritten with denominator 24.
Repeating Schedules
If one event repeats every 4 days and another repeats every 6 days, the LCM tells you when they happen on the same day again. Since LCM(4, 6) = 12, they line up every 12 days.
Cycle Problems
LCM appears in problems involving lights, gears, rotations, signals, and repeating patterns. It gives the first time all cycles return to a shared point.
GCD vs LCM
GCD and LCM are often taught together because they describe two sides of the same relationship. The GCD looks downward toward shared factors. The LCM looks upward toward shared multiples.
| Concept | Question It Answers | Typical Use |
|---|---|---|
| GCD | What is the largest number that divides all of these numbers? | Reducing fractions, simplifying ratios, equal grouping |
| LCM | What is the smallest number all of these numbers divide into? | Common denominators, schedules, repeating cycles |
| Coprime result | GCD equals 1 | Shows the numbers share no factor except 1 |
| Prime connection | Both depend on prime factor structure | Explains why the result works |
Common Mistakes With GCD and LCM
Thinking GCD and LCM Are Opposites
They are related, but they are not simple opposites. The GCD is a divisor. The LCM is a multiple. One usually gets smaller than the entered numbers, while the other usually gets larger.
Forgetting About Shared Prime Powers
Prime factors can repeat. In 72, the factorization is 2³ × 3². The powers matter. Ignoring them can lead to a wrong LCM or GCD.
Assuming Prime Numbers Always Have LCM Equal to Their Sum
Prime numbers do not work that way. If two different prime numbers are entered, their GCD is 1 and their LCM is their product. For example, GCD(5, 7) = 1 and LCM(5, 7) = 35.
Using Decimals or Negative Values
GCD and LCM are normally discussed for integers. This calculator is built for positive whole numbers. Decimals, fractions, and negative signs should not be entered.
Why GCD and LCM Matter in Prime Number Study
Prime numbers help explain the structure of every positive whole number. GCD and LCM use that structure in two different ways.
The GCD keeps only what the numbers share. The LCM keeps everything needed to cover all numbers. That makes both concepts useful for understanding divisibility, factor trees, prime factorization, relatively prime numbers, and modular arithmetic.
Plain rule: If you are looking for what numbers have in common, think GCD. If you are looking for when numbers meet again as multiples, think LCM.
FAQ
What is the GCD of two numbers?
The GCD is the greatest positive integer that divides both numbers without a remainder. For example, the GCD of 12 and 18 is 6.
What is the LCM of two numbers?
The LCM is the smallest positive number that is a multiple of both numbers. For example, the LCM of 12 and 18 is 36.
Can the GCD be larger than the numbers?
No. The GCD cannot be larger than the smallest entered positive number because it must divide every number in the set.
Can the LCM be smaller than the numbers?
No. For positive integers, the LCM is at least as large as the largest entered number. It can equal the largest number if that number is already a multiple of the others.
What does it mean if the GCD is 1?
It means the numbers are coprime. They share no positive divisor except 1.
How are prime numbers related to GCD and LCM?
Prime factorization explains both results. The GCD uses shared prime factors with the lowest powers, while the LCM uses all prime factors with the highest powers needed.