LCM & GCD Calculator
Calculate the Least Common Multiple (LCM) and Greatest Common Divisor (GCD) of two or more numbers with prime factorization. Free.
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?
What is the GCD?
Can I calculate for more than two numbers?
What is the LCM used for?
Is it free?
Was this tool helpful?