# 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 1001
- `exponent` (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:

```json
{
  "base": "4",
  "exponent": "13",
  "modulus": "497"
}
```

Response:

```json
{
  "result": {
    "value": "445"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "integer-mod-pow",
  "version": "1.0.0",
  "input": {
    "base": "4",
    "exponent": "13",
    "modulus": "497"
  }
}
```

### HTTP (no key)

```sh
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](/v1/tools/integer-mod-pow/versions/1.0.0).

### CLI

```sh
node cli.mjs run integer-mod-pow 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Integer mod inverse](/tools/integer-mod-inverse): Compute the modular multiplicative inverse of a modulo modulus, when it exists.
- [Rational power](/tools/rational-power): Raise a rational number to an integer exponent and return the exact reduced result.
- [Integer CRT](/tools/integer-crt): Solve a system of integer congruences (x ≡ remainder mod modulus) with the Chinese Remainder Theorem.
- [Array integer adjacent diff](/tools/array-integer-adjacent-diff): Replace an array of canonical integer strings with consecutive first differences.
- [Array integer clamp](/tools/array-integer-clamp): Clamp an array of canonical integer strings to optional inclusive min and max bounds.
- [Array integer cumulative sum](/tools/array-integer-cumulative-sum): Replace an array of canonical integer strings with equal-length prefix sums.
