Integer divmod
integer-divmod · version 1.0.0 · Numbers & math · free, no key needed
Integer quotient and remainder truncated toward zero.
Use when you need to: integer divmod · integer quotient remainder · divide integers with remainder.
Supported
- integer divmod
- integer quotient remainder
- divide integers with remainder
Not supported
- floor division
- euclidean remainder
- modular inverse
- floating point division
- rational division
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; plus signs, spaces, underscores, hex, exponents, and leading zeros are rejected.
- Values are parsed with BigInt. Each input may have at most 1000 digits excluding the sign.
- Quotient and remainder match JavaScript BigInt / and %: truncation toward zero, remainder sign follows the dividend.
- Divisor 0 is rejected.
- The identity quotient * divisor + remainder equals dividend holds, and the absolute remainder is strictly less than the absolute divisor.
- Outputs are canonical integer strings.
Input
dividend(string, required): max length 1001; pattern^-?(0|[1-9][0-9]*)$divisor(string, required): max length 1001; pattern^-?(0|[1-9][0-9]*)$
Output
quotient(string, required)remainder(string, required)
Limits
- max digits: 1000
Example
Request input:
{
"dividend": "17",
"divisor": "5"
}
Response:
{
"result": {
"quotient": "3",
"remainder": "2"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "integer-divmod",
"version": "1.0.0",
"input": {
"dividend": "17",
"divisor": "5"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/integer-divmod/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"dividend":"17","divisor":"5"}'
The machine-readable contract is at /v1/tools/integer-divmod/versions/1.0.0.
CLI
node cli.mjs run integer-divmod 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.
- 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.
- Integer add: Add two canonical signed integer strings and return their canonical sum.