Modular Exponentiation Calculator
Calculate base^exponent mod modulus instantly using the fast square-and-multiply algorithm, with a full step-by-step breakdown.
Inputs
Quick Examples
Enter values and click Calculate
Result
Exponent binary:
Steps:
Step-by-Step Trace
| Step | Bit | Operation | Current value (mod n) |
|---|
Copied!
Summary
Calculate base^exponent mod modulus instantly using the fast square-and-multiply algorithm, with a full step-by-step breakdown.
How it works
- Enter the base, exponent, and modulus in the input fields.
- Click "Calculate" (or press Enter) to run the algorithm.
- The calculator converts the exponent to binary and processes each bit.
- For each bit, the current value is squared and, if the bit is 1, multiplied by the base — all mod the modulus.
- The step-by-step trace table shows every intermediate result.
- The final result appears at the top alongside the total step count.
Use cases
- Verify RSA encryption and decryption results by hand.
- Check Diffie-Hellman key exchange intermediate values.
- Solve discrete logarithm and modular arithmetic homework problems.
- Validate Miller-Rabin primality test computations.
- Explore Euler's theorem and Fermat's little theorem examples.
- Debug cryptographic implementations during development.
- Teaching aid for university number theory and cryptography courses.
- Quick sanity-check for large-exponent modular arithmetic.
Frequently Asked Questions
Last updated: 2026-06-10 ·
Reviewed by Nham Vu