Find the Greatest Common Divisor and Least Common Multiple for 2 or more comma-separated numbers. Uses the Euclidean algorithm and BigInt for large integer accuracy.
Enter 2 or more integers separated by commas or spaces
GCD
6
Greatest Common Divisor
LCM
72
Least Common Multiple
GCD(12, 18, 24) = 6 LCM(12, 18, 24) = 72
The greatest common divisor is the largest positive integer dividing every input. The least common multiple is the smallest positive value divisible by every input.
For two values, repeatedly replace (a, b) with (b, a mod b) until the remainder is zero. The final non-zero value is the GCD. LCM follows from abs(a × b) / GCD(a, b).
function gcd(a, b) {
while (b) [a, b] = [b, a % b];
return Math.abs(a);
}
from math import gcd
lcm = abs(a * b) // gcd(a, b)
| Concept | Common use |
|---|---|
| GCD | Simplifying fractions and grouping |
| LCM | Repeating schedules and common denominators |
Inputs use arbitrary-precision BigInt, so very large integers avoid normal JavaScript number rounding.
This tool is provided for general informational and utility purposes only. Results may be inaccurate, incomplete, outdated, or contain errors. Always verify results before relying on or using them.
Some tools may use AI, automated processing, third-party services, or server-side processing. Do not rely on these tools as a substitute for professional advice.
Use at your own risk. BestToolOnline makes no guarantees regarding the accuracy, reliability, completeness, availability, or suitability of results, to the maximum extent permitted by applicable law.
See our Terms of Service and Privacy Policy for complete details.