GCD & LCM Calculator

Compute GCD and LCM of two numbers.

Simplifying a fraction, scheduling recurring events, or finding a common denominator all quietly depend on two related number theory concepts: the greatest common divisor and the least common multiple. This tool calculates both instantly for any two numbers.

An algorithm over 2,000 years old, still taught essentially unchanged

The Euclidean algorithm for finding the greatest common divisor (GCD) appears in Euclid's "Elements" (circa 300 BC) and is widely considered one of the oldest algorithms still in common practical use today — its core method (repeatedly replacing the larger of two numbers with the remainder of dividing it by the smaller, until the remainder reaches zero) is remarkably efficient, requiring far fewer steps than the more intuitive but slower approach of listing out and comparing every factor of both numbers, and it remains the standard method taught in modern computer science and number theory education.

How this tool calculates GCD and LCM

For GCD, the tool applies the Euclidean algorithm directly, repeatedly dividing and taking remainders until reaching zero, with the final non-zero remainder being the greatest common divisor; for LCM, it applies the relationship LCM(a,b) = (a × b) ÷ GCD(a,b), a formula that leverages the already-calculated GCD rather than requiring a separate, more laborious search for the smallest shared multiple.

Where GCD and LCM calculations are genuinely useful

  • Simplifying fractions — dividing a fraction's numerator and denominator by their GCD reduces it to its simplest possible form, a foundational skill in basic arithmetic and algebra.
  • Finding a common denominator when adding fractions — the LCM of two denominators gives the smallest common denominator needed to add or compare fractions accurately.
  • Scheduling and recurring event planning — determining when two different recurring schedules (like two buses running on different intervals) will next coincide is a direct LCM calculation.
  • Computer science and cryptography — GCD calculations appear throughout number theory-based algorithms, including certain steps within cryptographic key generation processes.

Frequently asked questions

What's the difference between GCD and LCM in practical terms? GCD (greatest common divisor) finds the largest number that divides evenly into both of your numbers, useful for simplifying or reducing; LCM (least common multiple) finds the smallest number that both of your numbers divide evenly into, useful for combining or synchronizing — they solve genuinely different, complementary problems.

Why is the Euclidean algorithm so much faster than checking every possible factor? Because it uses a mathematical shortcut (the GCD of two numbers equals the GCD of the smaller number and the remainder of dividing the larger by the smaller) that shrinks the problem dramatically with each step, typically reaching the answer in far fewer operations than would be needed to individually list and compare every factor of both original numbers, especially for large numbers.

Can GCD and LCM be calculated for more than two numbers at once? Yes — both concepts extend naturally to three or more numbers, typically calculated by applying the two-number formula repeatedly and progressively (finding the GCD or LCM of the first two numbers, then combining that result with the third number, and so on).

Further reading