# Power Mod Calculator

URL: https://speedycalculator.com/calculators/math/power-modulo/
Last updated: 2026-11-08

> The power mod calculator computes xʸ mod n exactly for very large exponents using fast modular exponentiation (square-and-multiply), and shows the steps.

## Inputs

- Base x
- Exponent y
- Modulus n

## Results

- xʸ mod n
- Equation
- Square-and-multiply steps

## Formula

```
c = xʸ mod n,  0 ≤ c < n
```

## Explanation

Modular exponentiation is the workhorse of public-key cryptography: RSA encryption, Diffie–Hellman key exchange and primality tests all compute huge powers modulo n. Computing xʸ first and then reducing would be impossible for 300-digit numbers.

### How to use the Power Mod Calculator

- **Base x**
- **Exponent y**
- **Modulus n**

Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.

### How it works

The exponent is read in binary. At each bit the running base is squared modulo n, and when the bit is 1 the result is multiplied by the base. Exact BigInt arithmetic is used.

## Worked example

Inputs: Base x: 4; Exponent y: 13; Modulus n: 497.

Results: **xʸ mod n = 445**; Equation = 4¹³ mod 497 = 445; Square-and-multiply steps = Square-and-multiply (exponent in binary 1101):
bit 1: result = result × 4 mod 497 = 4
bit 0: skip
bit 1: result = result × 256 mod 497 = 30
bit 1: result = result × 429 mod 497 = 445.

## Key terms

- **Modular exponentiation**: Computing powers modulo n.

## FAQ

**What is 4¹³ mod 497?**
445.

**Why not compute 4¹³ first?**
For large exponents the power has millions of digits; reducing at every step keeps numbers small.

**What is Euler's theorem?**
If gcd(x, n) = 1, x^φ(n) ≡ 1 (mod n), which can shorten exponents.

**Can the exponent be negative?**
Only with a modular inverse; this calculator needs y ≥ 0.


## Sources

- [Wolfram MathWorld: Power mod](https://mathworld.wolfram.com/PowerMod.html)
- [OpenStax: Contemporary Mathematics](https://openstax.org/details/books/contemporary-mathematics)
