GCD & LCM Calculator — Greatest Common Divisor & Least Common Multiple

Find the GCD and LCM of up to 10 integers. Enter comma-separated numbers.

  • GCD & LCM
  • Up to 10 numbers
  • Euclidean algorithm
  • Browser-only

GCD of [12, 18, 24] = 6

LCM of [12, 18, 24] = 72

About the GCD & LCM Calculator

Find the greatest common divisor (also called the HCF) and the least common multiple of two or more integers in one pass. It is the go-to check when simplifying fractions, finding a common denominator, or working out when repeating schedules line up. Switch the view between GCD, LCM or BOTH; negative numbers are allowed, and the results are always positive.

How to use the GCD & LCM Calculator

  1. Choose GCD, LCM or BOTH.
  2. Type your integers into the Numbers field, separated by commas or spaces.
  3. Read the result lines, which repeat the list of numbers actually used so you can confirm what was read.

Worked example: GCD and LCM of 84, 126 and 210

The tool folds the list pairwise. GCD(84, 126): 126 = 1 x 84 + 42, then 84 = 2 x 42 + 0, so 42. GCD(42, 210): 210 = 5 x 42 + 0, so the result is 42.

LCM(84, 126) = 84 x 126 / 42 = 252. LCM(252, 210) = 252 x 210 / GCD(252, 210) = 52,920 / 42 = 1,260.

Input
84, 126, 210
Output
GCD of [84, 126, 210] = 42
LCM of [84, 126, 210] = 1,260

Where each one is used

The GCD is the largest number that divides every value evenly. Dividing a fraction's top and bottom by their GCD reduces it in one step: 84/126 becomes 2/3 after dividing by 42. The LCM is the smallest number every value divides into. It gives the lowest common denominator for adding fractions, which the fraction calculator uses, and the first time repeating cycles coincide: buses every 12, 18 and 24 minutes all leave together every 72 minutes.

A GCD of 1 means the numbers are coprime. For 4, 6, 10 and 15 no number above 1 divides all four, so the GCD is 1 and the LCM is 60.

Edge cases the tool handles

  • Zeros and non-integers are dropped from the list. For 8, 0, 12 the result reads GCD of [8, 12] = 4, so check the echoed list.
  • Negative values are allowed: GCD(-12, 18) is 6 and the LCM is 36.
  • At least two usable integers are needed. LCMs grow quickly, and results past 9,007,199,254,740,991 lose precision.

GCD: what it means and when you need it

The GCD tells you the largest unit that evenly divides two quantities. This appears in simplifying fractions (divide numerator and denominator by their GCD), scheduling problems (two events repeating every 12 and 8 days coincide every LCM(12,8) = 24 days), and cryptography (RSA relies on choosing primes whose GCD is 1).

Two numbers are coprime if their GCD is 1. Coprime numbers share no common prime factors. Examples: 9 and 16, 35 and 12. Coprimality is a weaker condition than both numbers being prime.

The Euclidean algorithm: why it works

The algorithm exploits GCD(a, b) = GCD(b, a mod b). Any common divisor of a and b also divides a mod b. The algorithm iterates until the remainder is 0, at which point the previous remainder is the GCD.

The algorithm is efficient even for very large numbers. The number of steps is proportional to the number of digits, making it logarithmic in the input size — far faster than trial division.

GCD & LCM Calculator: frequently asked questions

What is the GCD?
The GCD (Greatest Common Divisor) of two integers is the largest integer that divides both without a remainder. GCD(12, 8) = 4. Also called HCF (Highest Common Factor).
What is the LCM?
The LCM (Least Common Multiple) is the smallest positive integer divisible by both numbers. LCM(4, 6) = 12. LCM is used when finding a common denominator for fractions.
How does the Euclidean algorithm find GCD?
Replace the larger number with the remainder of dividing larger by smaller. Repeat until the remainder is 0. The last non-zero remainder is the GCD. Example: GCD(48, 18): 48 = 2x18+12; 18 = 1x12+6; 12 = 2x6+0. GCD = 6.
What is the relationship between GCD and LCM?
LCM(a, b) = a times b divided by GCD(a, b). Example: LCM(12, 8) = 96 divided by GCD(12, 8) = 96 divided by 4 = 24.