Greatest common divisor and least common multiple
The greatest common divisor (GCD), also called the greatest common factor, is the largest whole number that divides all of your numbers without a remainder. The least common multiple (LCM) is the smallest positive number that is a multiple of all of them. Both come up constantly in maths: reducing fractions, finding common denominators, scheduling repeating events and number theory. This calculator finds both for two or more whole numbers at once.
How to use it
- Enter two or more whole numbers, separated by commas or spaces, for example
12, 18, 30. - Press calculate and read the GCD and LCM.
How it works
The GCD is calculated with the Euclidean algorithm, one of the oldest algorithms in mathematics: replace the larger number by the remainder of dividing it by the smaller one, and repeat until the remainder is zero. The last non-zero remainder is the GCD.
Example for 48 and 18: 48 = 2 × 18 + 12, 18 = 1 × 12 + 6, 12 = 2 × 6 + 0. The GCD is 6.
The LCM follows from the GCD: LCM(a, b) = a × b ÷ GCD(a, b). For 48 and 18 that is 864 ÷ 6 = 144. For more than two numbers, the calculator applies these steps one pair at a time.
Where you need GCD and LCM
- Reducing fractions: divide numerator and denominator by their GCD. 48/18 becomes 8/3.
- Adding fractions: the LCM of the denominators is the lowest common denominator. For 1/4 + 1/6 it is 12.
- Schedules: one bus runs every 12 minutes, another every 18 minutes. They leave together again after LCM(12, 18) = 36 minutes.
- Tiling and cutting: the largest square tile that fits a 120 × 80 cm area exactly has a side of GCD(120, 80) = 40 cm.
Good to know
If the GCD of two numbers is 1, they are called coprime. Their LCM is then simply their product.
Frequently asked questions
Can I enter more than two numbers?
Yes. Enter any number of whole numbers separated by commas or spaces.
What if one of the numbers is a prime?
If a prime does not divide the other numbers, the GCD is 1 and the numbers are coprime.
Does it work with negative numbers or decimals?
GCD and LCM are defined for whole numbers. Use positive integers for meaningful results.
Is my data stored or sent anywhere?
No. The calculation runs entirely in your browser. Nothing you enter is saved, tracked or sent to a server.