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

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

  1. Enter the base, exponent, and modulus in the input fields.
  2. Click "Calculate" (or press Enter) to run the algorithm.
  3. The calculator converts the exponent to binary and processes each bit.
  4. For each bit, the current value is squared and, if the bit is 1, multiplied by the base — all mod the modulus.
  5. The step-by-step trace table shows every intermediate result.
  6. 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