GCD & LCM Calculator — Free Online Tool

This online GCD & LCM calculator helps you find the Greatest Common Divisor (GCD) and Least Common Multiple (LCM) of numbers in seconds. Enter your inputs and get an instant result with the formula explained, ready for budgeting, planning, or quick decisions.

Numbers

Set to 0 to ignore

Results

GCD (Greatest Common Divisor)
12
LCM (Least Common Multiple)
72
GCD (First Two Numbers)
12
LCM (First Two Numbers)
72
Verification

GCD × LCM = Product (for two numbers)

Understanding GCD and LCM: Greatest Common Divisor and Least Common Multiple

The Greatest Common Divisor (GCD), also called the Greatest Common Factor (GCF), is the largest positive integer that divides two or more numbers without remainder. The Least Common Multiple (LCM) is the smallest positive integer that is divisible by two or more numbers. These concepts are fundamental in mathematics, essential for simplifying fractions, finding common denominators, solving number theory problems, and working with ratios. Understanding GCD and LCM helps you simplify fractions, add and subtract fractions, solve timing problems, and understand relationships between numbers. Whether you're working with fractions, solving word problems, or studying number theory, mastering GCD and LCM is essential for mathematical problem-solving.

Examples

GCD and LCM Calculation

Let's find the GCD and LCM of 12 and 18. GCD (Greatest Common Divisor) is the largest number that divides both numbers. LCM (Least Common Multiple) is the smallest number that both numbers divide into. To find GCD of 12 and 18, list their factors.

Factors of 12: 1, 2, 3, 4, 6, 12. Factors of 18: 1, 2, 3, 6, 9, 18. Common factors: 1, 2, 3, 6. The greatest is 6, so GCD(12, 18) = 6.

The Euclidean algorithm is more efficient for large numbers. Divide 18 by 12: 18 = 12 × 1 + 6. Now divide 12 by 6: 12 = 6 × 2 + 0. When remainder is 0, the last non-zero remainder is the GCD: 6.

For LCM, list multiples of each number. Multiples of 12: 12, 24, 36, 48, 60, 72.. Multiples of 18: 18, 36, 54, 72.. The smallest common multiple is 36.

Formula: LCM(a, b) = (a × b) / GCD(a, b). LCM(12, 18) = (12 × 18) / 6 = 216 / 6 = 36. GCD is used to simplify fractions to lowest terms. To simplify 12/18, divide both by GCD(12, 18) = 6: 12/18 = 2/3.

LCM is used to find common denominators for adding fractions. To add 1/12 + 1/18, use LCM(12, 18) = 36 as common denominator. Convert: 3/36 + 2/36 = 5/36. GCD and LCM are fundamental in number theory and practical arithmetic.

They appear in scheduling problems, gear ratios, and music theory. This example demonstrates how GCD and LCM connect and simplify calculations. Understanding these mathematical concepts helps in solving real-world problems. Mathematics is a powerful tool for logical thinking and problem-solving.

Regular practice with these calculations builds confidence and mathematical fluency.

Key properties

GCD: Largest Common Divisor

The GCD of two or more numbers is the largest positive integer that divides all of them evenly. For example, GCD(12, 18) = 6 because 6 is the largest number that divides both 12 and 18. The GCD is always at least 1 (since 1 divides every number) and at most the smallest of the numbers. Understanding GCD helps you simplify fractions and find common factors.

LCM: Smallest Common Multiple

The LCM of two or more numbers is the smallest positive integer that all of them divide evenly. For example, LCM(4, 6) = 12 because 12 is the smallest number divisible by both 4 and 6. The LCM is always at least as large as the largest number. Understanding LCM helps you find common denominators and solve timing problems.

Euclidean Algorithm: Efficient GCD Calculation

The Euclidean algorithm efficiently finds GCD by repeatedly applying: GCD(a, b) = GCD(b, a mod b) until b = 0. This is much faster than factorization for large numbers. For example, GCD(48, 18): 48 mod 18 = 12, then GCD(18, 12): 18 mod 12 = 6, then GCD(12, 6): 12 mod 6 = 0, so GCD = 6. Understanding the Euclidean algorithm helps you calculate GCDs efficiently.

Prime Factorization Method

Both GCD and LCM can be found using prime factorization. For GCD, take common prime factors with smallest exponents. For LCM, take all prime factors with largest exponents. For example, 12 = 2² × 3 and 18 = 2 × 3², so GCD = 2¹ × 3¹ = 6 and LCM = 2² × 3² = 36. Understanding prime factorization helps you see why these methods work.

GCD and LCM Relationship

GCD and LCM are related: GCD(a, b) × LCM(a, b) = a × b (for positive integers). This means if you know one, you can find the other. For example, if GCD(12, 18) = 6, then LCM = (12 × 18) / 6 = 36. Understanding this relationship helps you calculate one from the other.

GCD for Multiple Numbers

To find GCD of three or more numbers, find GCD of first two, then GCD of that result with the third, and so on: GCD(a, b, c) = GCD(GCD(a, b), c). Similarly for LCM: LCM(a, b, c) = LCM(LCM(a, b), c). Understanding this recursive approach helps you work with multiple numbers.

Formulas

Euclidean Algorithm for GCD

GCD(a, b) = GCD(b, a mod b), repeat until b = 0

This efficient algorithm finds GCD by repeated division. For example, GCD(48, 18): 48 mod 18 = 12, then GCD(18, 12): 18 mod 12 = 6, then GCD(12, 6): 12 mod 6 = 0, so GCD = 6.

LCM from GCD

LCM(a, b) = (a × b) / GCD(a, b)

This formula uses GCD to find LCM. For example, GCD(12, 18) = 6, so LCM = (12 × 18) / 6 = 216 / 6 = 36. This is often more efficient than factorization.

Prime Factorization for GCD

GCD = product of common primes with smallest exponents

For example, 12 = 2² × 3¹ and 18 = 2¹ × 3², common primes are 2 and 3, smallest exponents are 1 and 1, so GCD = 2¹ × 3¹ = 6.

Prime Factorization for LCM

LCM = product of all primes with largest exponents

For example, 12 = 2² × 3¹ and 18 = 2¹ × 3², all primes are 2 and 3, largest exponents are 2 and 2, so LCM = 2² × 3² = 36.

GCD and LCM in Mathematics and Applications

GCD and LCM are used in many areas: simplifying fractions by dividing numerator and denominator by their GCD, adding and subtracting fractions by finding LCM as common denominator, solving timing problems (when events occur together), scheduling problems (when things align), number theory problems, and modular arithmetic. Students learn GCD and LCM for working with fractions. Understanding GCD and LCM helps individuals simplify fractions, find common denominators, solve timing and scheduling problems, and understand relationships between numbers.

Frequently asked questions

What is the greatest common divisor (GCD)?

It is the largest positive integer that divides every number in your set without remainder. We use the Euclidean algorithm for speed.

How is the least common multiple (LCM) computed?

LCM multiplies the highest exponent of each unique prime. For pairs we also apply lcm(a,b) = |ab|/gcd(a,b).

Can I enter more than two numbers?

Yes—paste up to 20 integers and we iterate the GCD/LCM formulas across the list.

How do negative numbers affect the result?

We operate on absolute values but record the original signs in the explanation for clarity.

What if any number is zero?

gcd(0, n) equals |n|, while any LCM involving zero is zero. The tool highlights these special cases.

How do I use GCD to reduce fractions?

Compute the GCD of numerator and denominator, then divide both. This mirrors what the fraction calculator does behind the scenes.

When is LCM useful?

LCM finds shared time intervals, synchronizes repeating tasks, and determines least common denominators for fraction addition.

Does the tool show Euclidean steps?

Enable verbose mode to view each modulo operation until the remainder drops to zero.

Can I export prime factor tables?

Yes—download PDFs showing the prime factors of each number along with overlaps used for GCD/LCM.

How precise is the result?

All calculations run with arbitrary-precision integers, so there is no rounding error.

Why is gcd(1, n) always 1?

One divides every integer, making it the minimum positive GCD. The calculator flags this property for quick reference.

What about algebraic expressions?

Enter coefficients only. For polynomial GCDs consider a computer algebra system instead.

How do GCD and LCM relate?

For positive integers a and b, gcd(a,b) × lcm(a,b) = |a×b|. We display this identity so you can cross-check outputs.

Can I compare multiple scenarios?

Use the history sidebar to revisit prior computations and contrast them quickly.

Where can I learn more?

See the linked number theory primer or jump to the factors calculator for foundational concepts.