onlinecalculator.me

GCD and LCM calculator

The GCD is the largest number that divides all inputs evenly. The LCM is the smallest number that all inputs divide into evenly.

GCD

Greatest Common Divisor

LCM

Least Common Multiple

About this calculator

Algorithm

GCD uses Euclid’s algorithm (approximately 300 BC — one of the oldest algorithms still in use):

GCD(a, b):
  while b ≠ 0:
    a, b = b, a mod b
  return a

LCM is derived from GCD:

LCM(a, b) = |a × b| / GCD(a, b)

For more than two numbers, apply pairwise: GCD(a, b, c) = GCD(GCD(a, b), c).

Examples

NumbersGCDLCM
12, 18636
4, 6212
7, 13191
12, 18, 24672
What is GCD?
GCD (greatest common divisor), also called GCF (greatest common factor) or HCF (highest common factor), is the largest positive integer that divides all given numbers without remainder. GCD(12, 18) = 6 because 6 is the largest number that divides both 12 and 18.
What is LCM?
LCM (least common multiple) is the smallest positive integer that is divisible by all given numbers. LCM(4, 6) = 12 because 12 is the smallest number that both 4 and 6 divide into evenly.
How is GCD calculated?
The calculator uses Euclid's algorithm: GCD(a, b) = GCD(b, a mod b), repeated until b = 0. It then reduces multiple numbers by applying GCD pairwise.
What is the relationship between GCD and LCM?
For two numbers a and b: LCM(a, b) = |a × b| / GCD(a, b). This is why reducing the GCD first prevents overflow.
How do I share my calculation?
Click "Share with my numbers" to copy a URL that reopens with your input.