Calculate Greatest Common Divisor and Least Common Multiple of multiple numbers. Shows prime factorization and common divisors.
Find the greatest common divisor (GCD) and least common multiple (LCM) of two or more integers. Add as many numbers as you like; results appear instantly along with the prime factorization of each input and the common divisors they share.
Initializing in your browser…
You need the greatest common divisor and least common multiple of 48 and 180 for a fraction-reduction step.
Numbers
48 and 180
Result
GCD = 12 LCM = 720 (48 = 2⁴·3, 180 = 2²·3²·5)
From the prime factorisations, GCD takes the lowest shared powers (2²·3 = 12) and LCM the highest (2⁴·3²·5 = 720), and indeed GCD × LCM = 48 × 180. Showing the factorisation makes the relationship between the two results clear instead of magical.
Find the greatest common divisor (GCD) and least common multiple (LCM) of two or more integers. Add as many numbers as you like; results appear instantly along with the prime factorization of each input and the common divisors they share.
The calculator works on a list of integers - two input fields by default, with an Add button to append more and a trash icon to remove any once you have more than two. Each field is sanitized as you type so only digits and a single leading minus survive, and the result engine runs parseInt over the list and silently drops any entry that is NaN or zero, so you need at least two valid non-zero integers before anything is computed. The GCD is found with the classic Euclidean algorithm (a repeated `a mod b` loop until the remainder is zero), and because every value is passed through Math.abs first, negative inputs like -12 are treated by magnitude. For three or more numbers, both the GCD and LCM are reduced pairwise with a left fold - gcd(a, b, c) is computed as gcd(gcd(a, b), c) - rather than by any single multi-argument formula.
The LCM is derived from the identity lcm(a, b) = |a x b| / gcd(a, b) rather than by listing multiples, which keeps it exact for the pairwise fold. Because that product can grow quickly, the LCM panel switches to JavaScript exponential notation with four decimals (toExponential(4)) whenever the value exceeds 999,999,999,999, while smaller results use grouped thousands separators. Alongside the two headline numbers, the tool prints a prime factorization for each input using trial division up to the square root, formatted with caret exponents - so 12 renders as 2^2 x 3 and 18 as 2 x 3^2 - and a chip list of every common divisor, which it computes as the divisors of the GCD (the divisors of the GCD are exactly the divisors shared by all inputs).
When you enter exactly two numbers, an extra Verification panel demonstrates the GCD x LCM = |a x b| relationship explicitly: it shows GCD x LCM, evaluates that product, shows |a| x |b| beside it, and prints a green check mark when the two match. This panel only appears in the two-number case - it is not shown for three or more inputs, since the simple product identity does not generalize. Note that despite what older descriptions may suggest, the tool does not print an iterative step-by-step Euclidean trace; it shows the final GCD and LCM plus the factorization, common-divisor, and (for two numbers) verification panels. Every result recomputes instantly via a memoized hook as you edit fields, and both the GCD and LCM values have one-click copy buttons.
Add a third field and enter 48, 18, 24. The tool folds pairwise to GCD 6 and LCM 144, lists factorizations 48 = 2^4 x 3, 18 = 2 x 3^2, 24 = 2^3 x 3, and shows the common divisors of the GCD (1, 2, 3, 6). With three numbers no Verification panel appears.
Enter 12 and 18 to get GCD 6 and LCM 36. The Verification panel shows 6 x 36 = 216 and |12| x |18| = 216 with a green check, demonstrating the GCD x LCM = |a x b| identity that only displays in the two-number case.
Yes. The tool computes the GCD and LCM across any number of inputs by iterating pairwise. You need at least two non-zero integers.
For two numbers a and b: GCD(a, b) x LCM(a, b) = |a x b|. The tool shows this verification when exactly two numbers are entered.
Every calculation runs locally in your browser. Your numbers and expressions are not transmitted or stored.