Power mod calculator: modular exponentiation

Power Mod Calculator

Enter the terms as x to the power y mod n = res and it will automatically calculate the result.




Convert

x y mod n = res

Modular exponentiation: why huge powers stay small

Computing (baseexponent) mod m is a core operation in cryptography — it's what RSA and Diffie–Hellman key exchange are built on. The problem: raising a base to a large exponent produces numbers too big for an ordinary calculator to hold. This tool uses "exponentiation by squaring" to return the remainder directly, without ever constructing the full power. Here's how the method works and why a maths trick underpins modern encryption.

Clock arithmetic in 30 seconds

Modular arithmetic is often called clock arithmetic. On a 12-hour clock, 10:00 plus 4 hours is 2:00, not 14:00 — the numbers wrap around at 12. Written mathematically: (10 + 4) mod 12 = 2. A "mod" operation just returns the remainder after division: 14 ÷ 12 = 1 with remainder 2. Everything below follows from that single idea.

A worked example, step by step

Let's compute 74 mod 13 the naive way first: 7² = 49, 49² = 2,401, and 2,401 ÷ 13 = 184 remainder 9, so the answer is 9. Now the fast way, which keeps numbers tiny:

With a huge exponent like 51000000 mod 7, the same trick keeps every intermediate value below 7² — the calculator never builds the million-digit power.

Why modular exponentiation matters

The three inputs and what they mean

Input Example Meaning
Base (x) 5 The number being repeatedly multiplied.
Exponent (y) 3 How many times the base multiplies itself (5³ = 125).
Modulus (n) 10 What to divide by; the remainder is the answer (125 mod 10 = 5).

Questions about this tool

What if I leave the exponent blank?

It becomes a plain modulo calculation: base mod n — handy for quick remainder checks.

What if I leave the modulus blank?

It becomes ordinary exponentiation: baseexponent. Careful with very large exponents — without a modulus to wrap the numbers, even the browser can hit a limit.

How large a number can this handle?

The tool runs in JavaScript using BigInt, so it can work with exponents and moduli far beyond what a 64-bit processor or spreadsheet handles. Everything runs locally in your browser — nothing is sent to a server and it works offline.

Does it support negative or fractional inputs?

Modular exponentiation with fractional exponents isn't defined the way it is for integers, and negative exponents mean modular inverses rather than plain powers. This tool expects non-negative integers, which covers the RSA-style use case it was built for.