Modular Exponentiation
Fast aᵇ mod m by repeated squaring
4^13 mod 497
a^b mod m
445
Base reduced (a mod m)
4
Exponent in binary
1101
Repeated-squaring ladder
| k | bit | a^(2^k) mod m | running result |
|---|---|---|---|
| 0 | 1 | 4 | 4 |
| 1 | 0 | 16 | 4 |
| 2 | 1 | 256 | 30 |
| 3 | 1 | 429 | 445 |
Über diesen Rechner
The Modular Exponentiation Calculator computes a^b mod m exactly using right-to-left binary exponentiation (repeated squaring), the same fast algorithm behind RSA and Diffie–Hellman. It handles huge bases and exponents with exact big-integer arithmetic, normalizes negative bases into [0, m), and shows the full squaring ladder bit by bit so you can follow how each exponent bit folds into the result. Useful for cryptography, number theory, and competitive-programming study.
Häufige Beispiele
- 3^4 mod 5 = 1 (81 mod 5)
- 2^10 mod 1000 = 24 (1024 mod 1000)
- 7^128 mod 13 = 3, computed in 8 squarings rather than 128 multiplications
- a^0 mod m = 1 for any base (0^0 = 1 by convention)
- (-3)^3 mod 7 = 1, since −3 ≡ 4 (mod 7) and 4^3 = 64 ≡ 1