Integer mod inverse
integer-mod-inverse · version 1.0.0 · Numbers & math · free, no key needed
Compute the modular multiplicative inverse of a modulo modulus, when it exists.
Use when you need to: integer mod inverse · modular multiplicative inverse · modular inverse.
Supported
- integer mod inverse
- modular multiplicative inverse
- modular inverse
- inverse mod m
Not supported
- modular exponentiation
- extended gcd output
- inverse when gcd is not 1
Behavior
- a and modulus are canonical integer strings; modulus must be a positive canonical integer.
- a may be negative or exceed modulus; it is reduced modulo modulus before inverting.
- The inverse exists only when gcd(a mod modulus, modulus) = 1; otherwise the request is rejected as undefined.
- modulus 1 is a degenerate ring where every residue is 0; this contract returns value 0 for modulus 1.
- The result is the unique value in [0, modulus) such that (a * value) mod modulus = 1 (or 0 when modulus is 1).
- Each input may have at most 1000 digits excluding sign.
Input
a(string, required): min length 1; max length 1001modulus(string, required): min length 1; max length 1001
Output
value(string, required)
Limits
- max digits: 1000
Example
Request input:
{
"a": "3",
"modulus": "11"
}
Response:
{
"result": {
"value": "4"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "integer-mod-inverse",
"version": "1.0.0",
"input": {
"a": "3",
"modulus": "11"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/integer-mod-inverse/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"a":"3","modulus":"11"}'
The machine-readable contract is at /v1/tools/integer-mod-inverse/versions/1.0.0.
CLI
node cli.mjs run integer-mod-inverse 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Integer mod pow: Compute base^exponent mod modulus exactly using fast modular exponentiation.
- Integer CRT: Solve a system of integer congruences (x ≡ remainder mod modulus) with the Chinese Remainder Theorem.
- Rational reciprocal: Invert a rational number given as a numerator/denominator integer-string pair.
- Array integer adjacent diff: Replace an array of canonical integer strings with consecutive first differences.
- Array integer clamp: Clamp an array of canonical integer strings to optional inclusive min and max bounds.
- Array integer cumulative sum: Replace an array of canonical integer strings with equal-length prefix sums.