Modular Exponentiation Calculator

Compute (base ^ exponent) mod modulus for huge numbers.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

This calculator computes (base ^ exponent) mod modulus — the core operation of RSA, Diffie-Hellman and other public-key cryptography. It is built for students and developers who need an exact result for large inputs that ordinary calculators cannot handle.

How it works

It uses the square-and-multiply (binary exponentiation) algorithm with arbitrary-precision integers. The exponent is read bit by bit: at each step the running base is squared, and whenever the current bit is 1 the result is multiplied in. Crucially, the value is reduced modulo the modulus after every multiplication, so intermediate numbers never exceed the modulus squared. This means even thousand-bit exponents compute almost instantly and exactly.

Example

To compute 4¹³ mod 497:

The exponent 13 is 1101 in binary. Square-and-multiply walks those bits, reducing mod 497 each step, giving 445 — without ever forming the full 8-digit value of 4¹³ (67,108,864).

baseexponentmodulusresult
413497445
7256139
210100024

All arithmetic uses arbitrary-precision integers and runs locally in your browser; nothing is uploaded.

Ad placeholder (rectangle)