Greatest Common Divisor of a List
Compute the nonnegative greatest common divisor of 1–1,000 signed decimal integers; an all-zero list has gcd zero.
Description
The greatest common divisor is the nonnegative integer dividing every supplied integer.
The greatest common divisor is the nonnegative integer dividing every supplied integer. Signed inputs share the same gcd as their absolute values.1
The tool returns gcd. The indexing and output conventions below determine how to read these values.
When to use Greatest Common Divisor of a List
Use this for the following task: Compute the nonnegative greatest common divisor of 1–1,000 signed decimal integers; an all-zero list has gcd zero. Use the input and output conventions below to reproduce the intended mathematical quantity.
How to use Greatest Common Divisor of a List and understand its results
- Choose the required indexes, integers or sequence entries. Preserve decimal-string encodings where the field table specifies strings.
- Enter values according to the field table, then run the tool.
- Read gcd. Preserve exact decimal strings and the stated indexing or coefficient order.
- Keep exact decimal strings for subsequent integer arithmetic; distinguish them from any explicitly approximate numeric result.
| Input field | Meaning | Value type and bounds | Requirement |
|---|---|---|---|
| values | Signed decimal integers | list of string (integer/arbitrary); minimum entries 1; maximum entries 1000; each entry: maximum text length 200; pattern ^-?(0|[1-9][0-9]*)$ | Required |
Read 1–1000 signed decimal strings with BigInt, take each absolute value and combine it with a running gcd initialized at zero.
gcd list = repeated Euclidean remainder reduction The symbols and boundary conditions refer to the supplied fields and the implementation described above.
| Output field | Meaning | Value type |
|---|---|---|
| gcd | Greatest common divisor | string (integer/arbitrary) |
{
"input": {
"values": [
"84",
"-126",
"210"
]
},
"output": {
"gcd": "42"
}
} Limitations and assumptions
An all-zero list returns zero. Inputs are exact decimal text with at most 200 characters per value; no Bézout coefficient is returned.
Use the declared integer bounds and string formats. Large exact outputs remain decimal strings; numerical approximations use ordinary floating-point arithmetic. A rejected input is different from a valid zero count or false membership flag.
Alternative or Complementary methods
Choose Least Common Multiple of a List when you need its operation: Compute the nonnegative least common multiple of 1–128 signed decimal integers using exact arithmetic; any zero entry makes the result zero. Choose Extended Euclidean Coefficients for the complementary operation: Find exact decimal coefficients x and y satisfying a·x+b·y=gcd(a,b), with a nonnegative gcd and deterministic coefficients even when both inputs are zero.
Background reference: The Euclidean Algorithm.
References
-
The Euclidean Algorithm — Wissam Raji, Mathematics LibreTexts
Similar or alternative tools
- Least Common Multiple of a List
Compute the nonnegative least common multiple of 1–128 signed decimal integers using exact arithmetic; any zero entry makes the result zero.
- Extended Euclidean Coefficients
Find exact decimal coefficients x and y satisfying a·x+b·y=gcd(a,b), with a nonnegative gcd and deterministic coefficients even when both inputs are zero.