Integer GCD
integer-gcd · version 1.0.0 · Numbers & math · free, no key needed
Compute the non-negative greatest common divisor of two canonical integer strings.
Use when you need to: integer gcd · greatest common divisor of two integers · gcd of integers.
Supported
- integer gcd
- greatest common divisor of two integers
- gcd of integers
Not supported
- least common multiple
- gcd of more than two integers
- floating-point gcd
- polynomial gcd
Behavior
- Inputs are canonical integer strings: 0 or an optional ASCII minus followed by a non-zero leading digit.
- The input -0 is accepted and canonicalized to 0 before evaluation.
- Integers are parsed with BigInt. A plus sign, spaces, underscores, hex, scientific notation, empty strings, and leading zeros other than 0 are rejected.
- Each input may have at most 1000 digits excluding the sign.
- The result is the non-negative greatest common divisor as a canonical integer string.
- gcd(0, n) and gcd(n, 0) equal |n|. gcd(0, 0) is rejected as undefined.
Input
a(string, required): min length 1; max length 1001b(string, required): min length 1; max length 1001
Output
value(string, required): min length 1; max length 1000
Limits
- max digits: 1000
Example
Request input:
{
"a": "48",
"b": "18"
}
Response:
{
"result": {
"value": "6"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "integer-gcd",
"version": "1.0.0",
"input": {
"a": "48",
"b": "18"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/integer-gcd/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"a":"48","b":"18"}'
The machine-readable contract is at /v1/tools/integer-gcd/versions/1.0.0.
CLI
node cli.mjs run integer-gcd 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Array integer GCD: Compute the non-negative greatest common divisor of an array of canonical integer strings.
- Integer LCM: Compute the non-negative least common multiple of two canonical integer strings.
- Array integer LCM: Compute the non-negative least common multiple of an array of canonical integer strings.
- Array integer min max: Return the numeric minimum and maximum of canonical integer strings.
- Array integer mode: Return the most frequent canonical integers, listing every mode in first-seen order.
- Array integer ranks: Assign competition (1224) ranks to canonical integers; ties share the minimum rank.