Last updated October 5, 2026 · Report an error
Computing a huge power directly (like 7^128) would produce an astronomically large number before ever taking the modulus — fast exponentiation avoids this entirely by squaring and reducing at every step.
This calculator computes base^exponent mod modulus using the same repeated-squaring technique used in real-world cryptography.
How it works
Enter the base, exponent, and modulus. The calculator converts the exponent to binary and processes it bit by bit — squaring the running base value each step, and multiplying it into the result whenever that bit is 1 — taking the modulus after every multiplication to keep numbers small.
- Enter base.
- Enter exponent.
- Enter modulus.
- Click Calculate to see your results.
Examples
7^128 mod 13
7 raised to the 128th power, mod 13, equals 3 — computed using only about 7 multiplications instead of 128, thanks to repeated squaring.
Who should use it
- Understanding how modular exponentiation and fast exponentiation work for a cryptography or number theory course.
- Checking a hand-computed modular exponentiation result.
Industry applications
- Cryptography and computer security education
- Computer science and number theory coursework
Advantages
- Uses the same efficient repeated-squaring algorithm real cryptographic systems rely on.
- Shows the exponent's binary representation and the squaring trace step by step.
Limitations
- Purely a calculation tool — doesn't implement a full cryptographic protocol like RSA itself.
Common mistakes to avoid
- Assuming this calculator computes the literal (huge) value of base^exponent before taking the modulus — it never does, by design.
- Confusing modular exponentiation with modular multiplication, which is just one step within this larger algorithm.
Best practices
- For small exponents, verify the result by direct calculation to build confidence in how the algorithm works before trusting it on larger numbers.
Tips
- Fast exponentiation (also called "exponentiation by squaring") is a foundational technique in computer science — the same divide-and-conquer idea shows up in fast matrix exponentiation and other algorithms too.