GCD and LCM Calculator
Find the exact greatest common divisor and least common multiple of 2–20 integers. Inspect progressive reductions, divisibility checks and Euclidean division steps.
YOUR CALCULATION
Result
—
Calculation steps
Work through one step at a time or reveal the complete calculation. The steps use your current inputs.
How to calculate
Use absolute values and Euclid’s repeated-remainder algorithm for the GCD. Combine LCM values with LCM(a,b) = |a/GCD(a,b) × b|, dividing before multiplication. Repeat across the whole list using exact integer arithmetic.
GCD(a,b) = GCD(b, a mod b); LCM(a,b) = |a/GCD(a,b) × b| for nonzero a,b
Worked example
For 12, 18 and 30, the GCD is 6 and the LCM is 180. Divide each value by 6 to get 2, 3 and 5; 180 divided by each absolute input gives 15, 10 and 6.
Assumptions and input details
Signs do not affect GCD or LCM. This tool uses the conventions GCD(0,0)=0 and LCM=0 whenever any input is zero; these zero cases are stated explicitly rather than interpreted as a positive shared interval. Decimal numbers, fractions and scientific notation are rejected. Commas separate integers and are not thousands punctuation. All integer results are exact, including results beyond JavaScript’s ordinary number range. The first pair’s Euclidean trace shows at most 40 division rows; all calculations continue to completion.
References: OpenStax: greatest common divisor · OpenStax: common divisors and multiples
Using this calculator
Can I enter my own problem?
Yes. Replace the example values with your own inputs. The result, calculation steps, tables and applicable diagrams update from those inputs. Blank or invalid values clear the result; example values are never silently substituted for missing inputs.
Are the results exact?
Fraction, counting, number-base and integer-factor results use exact integer arithmetic. Any decimal or percentage display is approximate.
Is my input uploaded?
The calculation runs in your browser. No account, file upload or external AI service is required. Inputs are not saved between page reloads.
Add, subtract, multiply or divide fractions and mixed numbers. Follow exact fraction steps, simplification and a number-line diagram.
Count ordered or unordered selections, with or without repetition. Read the exact integer result, compare all four cases and list examples for small problems.
Find the nth term and sum of an arithmetic or geometric sequence. Inspect terms, running totals, a term graph and a convergent geometric sum where applicable.
Reserved advertising space.