Power Mod Calculator

Quick answer

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

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

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

  1. Base x
  2. Exponent y
  3. 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.

Formula

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

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.

Frequently asked questions

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

  1. Wolfram MathWorld: Power mod
  2. OpenStax: Contemporary Mathematics

Cite this calculator

Speedy Calculator. (2026). Power Mod Calculator. Speedy Calculator. https://speedycalculator.com/calculators/math/power-modulo/