Wide Tools

LCM & GCD Calculator

Calculate the Least Common Multiple (LCM) and Greatest Common Divisor (GCD) of two or more numbers with prime factorization. Free.

Examples:

When do you need the LCM and GCD?

The Least Common Multiple (LCM) answers: "what is the smallest number all these values divide into evenly?" The classic use case is adding fractions with different denominators — you need the LCM to find the common denominator. It also comes up when synchronizing repeating events: if one bus runs every 12 minutes and another every 18 minutes, the LCM (36 minutes) tells you when both depart simultaneously.

The Greatest Common Divisor (GCD) answers: "what is the largest number that divides all of these evenly?" It simplifies fractions (divide numerator and denominator by their GCD to get the lowest terms) and solves equal-division problems — like cutting ribbons of 12 cm and 18 cm into equal pieces as large as possible (GCD = 6 cm).

How the calculator finds the answer

Under the hood, this tool uses prime factorization: it breaks every number into its prime factors, then computes the GCD by taking the lowest power of each common prime, and the LCM by taking the highest power of every prime that appears. For example, 12 = 2² × 3 and 18 = 2 × 3²: GCD = 2¹ × 3¹ = 6, LCM = 2² × 3² = 36. The calculator shows the full factorization so you can verify each step — useful when checking homework or understanding where the result comes from.

Useful identity: LCM × GCD = product of the two numbers

For any two positive integers a and b: LCM(a, b) × GCD(a, b) = a × b. This means once you know either the LCM or the GCD, you can derive the other with a single multiplication and division — no factorization needed. This identity only holds for exactly two numbers; for three or more, the relationship is more complex, which is why the calculator extends prime factorization to handle multiple inputs at once.

Frequently asked questions

What is the LCM?
The Least Common Multiple (LCM) is the smallest positive integer divisible by all numbers in a set. For example, the LCM of 4 and 6 is 12, since 12 is the smallest number divisible by both.
What is the GCD?
The Greatest Common Divisor (GCD) is the largest integer that divides all numbers in a set exactly. For example, the GCD of 12 and 18 is 6, since 6 is the largest common divisor.
Can I calculate for more than two numbers?
Yes! Enter as many numbers as you like separated by commas — for example: 12, 18, 24, 36. The calculator solves for all simultaneously.
What is the LCM used for?
The LCM is used to add and subtract fractions with different denominators, find repeating cycles (gears, traffic lights) and solve equal-division problems.
Is it free?
Yes, 100% free with no sign-up required.

Was this tool helpful?

Get updates

We'll let you know when we launch new tools. No spam.