GCD & LCM Calculator
NewCalculate the greatest common divisor and least common multiple of two or more integers, with a visible step-by-step Euclidean algorithm trace.
Euclidean algorithm steps
GCD is computed pairwise using the Euclidean algorithm (gcd(a,b) = gcd(b, a mod b), until b reaches 0), then reduced across all numbers. LCM is derived from the GCD using lcm(a,b) = |a·b| / gcd(a,b), extended pairwise across the full list.
Frequently Asked Questions
How does the Euclidean algorithm find the GCD?
It repeatedly replaces the larger number with the remainder of dividing it by the smaller number (gcd(a,b) = gcd(b, a mod b)) until the remainder reaches 0 — whatever number remains is the GCD. It's one of the oldest known algorithms and is extremely fast even for very large numbers.
How is LCM calculated from the GCD?
The formula lcm(a,b) = |a·b| / gcd(a,b) works because multiplying two numbers and dividing out their shared factors (the GCD) leaves exactly the smallest number both divide into evenly.
Can I enter more than two numbers?
Yes — enter any number of integers separated by commas or spaces. The tool reduces them pairwise (gcd of the running result and the next number), which correctly extends both GCD and LCM to any list length.
What happens if I enter negative numbers?
GCD and LCM are conventionally defined using absolute values, so negative inputs are automatically treated as their positive equivalents — gcd(-48, 180) gives the same result as gcd(48, 180).
Related Tools
Math Expression Evaluator
NewEvaluate mathematical expressions safely — supports arithmetic, trig, logs, sqrt, and more.
Prime Number Tools
NewCheck if a number is prime, find primes up to N, prime factorization, and nearest prime finder.
Percentage Calculator
NewCalculate percentages, percent change, and percent increase/decrease instantly.