Compare −6, 9 and −12 by absolute value
Input and settings
Integers: -6 9 -12 (whitespace separated)
Expected result
GCD: 3 / LCM: 36
Calculate the greatest common divisor and least common multiple of two or more integers exactly. Handle large integers, negatives and zero, then copy or save TXT and JSON.
Separate plain integers with line breaks, spaces or tabs. Use 2–1,000 integers, each with up to 1,000 digits excluding its sign. Decimals, exponents, commas and fraction notation are not supported. UTF-8 input limit: 1 MB.
LCM limit: 10,000 digits. TXT and JSON output: 16,000 bytes each. Inputs and results are neither stored nor sent.
Check GCD and LCM conventions for signed integers and lists containing zero.
Example buttons replace the inputs and settings above and calculate. Restore previous input steps back one example at a time. After trying multiple examples, repeat restore to return to your original input. This history is lost when the page closes.
Integers: -6 9 -12 (whitespace separated)
GCD: 3 / LCM: 36
Integers: 0 6 9
GCD: 3 / LCM: 0
Negative inputs use their absolute values. Three divides 6, 9 and 12, while 36 is their least positive common multiple. This tool defines LCM as zero when any input is zero; do not interpret that as a positive repeat interval. Its all-zero GCD convention is also zero.
Separate 2–1,000 integers with spaces, newlines or tabs. Commas, decimals and exponents are unsupported. Each integer allows 1,000 digits including leading zeros but excluding the sign; total input is limited to 1,000,000 UTF-8 bytes. BigInt gives exact arithmetic, capped at 10,000 LCM digits and 16,000 output bytes. Finding a zero does not skip validation of the remaining input.
Verification: existing functions cover absolute values, mixed/all zeros, digit/count limits and exact large integers. Browser checks compare both Worker results, JSON downloads and restoration after multiple examples.
For the example 12, 18, 24, the GCD is 6 and the LCM is 72. The GCD is the greatest positive integer dividing every value; for positive inputs, the LCM is the smallest positive integer divisible by every value.
Negative inputs use their absolute values. For -6 and 9, the GCD is 3 and LCM 18. Duplicates count as inputs but do not change the GCD or LCM.
If any input is zero, the GCD is obtained from the remaining integers and the LCM is zero. For an all-zero list, this tool defines both GCD and LCM as zero. Use positive integers when modeling repeating intervals or periods.
Inputs and results remain exact integer strings without rounding. An LCM exceeding 10,000 digits produces an error and cannot be saved as a partial result. All inputs are validated before applying the zero-LCM rule, so a zero anywhere prevents a false overflow error from an intermediate product.
TXT contains two lines labeled GCD and LCM. JSON contains count, GCD, LCM and the negative/zero conventions; it does not include the original list. Large JSON results are strings. Files use UTF-8 without a BOM or added trailing newline.
Editing cancels in-progress work and clears the previous result. Cancel retains the input; Reset clears input and results.
Negatives are treated as absolute values. Any zero makes the LCM zero; this tool also defines the all-zero GCD as zero.
The GCD is 1. The LCM comes from the other integers, unless any zero makes it zero.
Yes. Copy and save include the complete result up to the 10,000-digit LCM limit. Above that limit the tool reports an error instead of truncating the result.
Share only the tool name and public URL. Your input and results are not included.
Keep any content you need before clearing. This tool does not autosave inputs or results. Reloading or closing the page, clearing inputs or resetting may discard your work.
Favorites and language preferences are stored separately and may be lost when site data is cleared. Tool resets and site-data deletion do not delete files already downloaded to your device.