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).
| base | exponent | modulus | result |
|---|---|---|---|
| 4 | 13 | 497 | 445 |
| 7 | 256 | 13 | 9 |
| 2 | 10 | 1000 | 24 |
All arithmetic uses arbitrary-precision integers and runs locally in your browser; nothing is uploaded.