Integer mod pow
integer-mod-pow · version 1.0.0 · Numbers & math · free, no key needed
Compute base^exponent mod modulus exactly using fast modular exponentiation.
Use when you need to: integer mod pow · modular exponentiation · modular power.
Supported
- integer mod pow
- modular exponentiation
- modular power
- fast exponentiation mod m
Not supported
- negative exponent
- modular inverse
- floating-point power
Behavior
- base and exponent are canonical integer strings; modulus is a canonical integer string.
- exponent must be non-negative; a negative exponent is rejected (use integer-mod-inverse first for negative exponents).
- modulus must be a positive canonical integer; zero and negative moduli are rejected.
- base may be negative or exceed the modulus; it is reduced modulo modulus before exponentiation, matching mathematical convention (result is always in [0, modulus)).
- modulus 1 always yields 0.
- The result is base^exponent mod modulus as a canonical non-negative integer string, computed by binary exponentiation so exponent size does not cause a slow loop.
- Each input may have at most 1000 digits excluding sign; the result has fewer digits than modulus.
Input
base(string, required): min length 1; max length 1001exponent(string, required): max length 1000; pattern^(0|[1-9][0-9]*)$modulus(string, required): min length 1; max length 1001
Output
value(string, required)
Limits
- max digits: 1000
Example
Request input:
{
"base": "4",
"exponent": "13",
"modulus": "497"
}
Response:
{
"result": {
"value": "445"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "integer-mod-pow",
"version": "1.0.0",
"input": {
"base": "4",
"exponent": "13",
"modulus": "497"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/integer-mod-pow/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"base":"4","exponent":"13","modulus":"497"}'
The machine-readable contract is at /v1/tools/integer-mod-pow/versions/1.0.0.
CLI
node cli.mjs run integer-mod-pow 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Integer mod inverse: Compute the modular multiplicative inverse of a modulo modulus, when it exists.
- Rational power: Raise a rational number to an integer exponent and return the exact reduced result.
- Integer CRT: Solve a system of integer congruences (x ≡ remainder mod modulus) with the Chinese Remainder Theorem.
- 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.