Modular Exponentiation

Fast aᵇ mod m by repeated squaring

About this calculator

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.

How to use the Modular Exponentiation calculator

  1. Enter the values for your problem into the input fields.
  2. Read the result — it updates instantly as you type.
  3. Check the formula and the visual explanation to follow how the answer was found.
  4. Copy the page URL to share the exact calculation.

Common examples

  • 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

Frequently asked questions

How does the Modular Exponentiation calculator work?

Enter your values and the calculator applies the exact mathematical method for this problem, showing the result together with the formula it used. Everything is computed with high-precision arithmetic, so the answer you see is not limited by ordinary floating-point rounding.

When would I use the Modular Exponentiation calculator?

It is useful for homework and exam preparation, for checking work done by hand, and whenever a step in a larger problem needs this calculation done quickly and reliably.

How accurate are the results?

Calculations run at 30 significant digits of precision internally. Displayed values are rounded for readability, but the underlying result is far more precise than a typical hand or pocket-calculator computation.

Can I share a specific calculation with someone else?

Yes. Every value you enter updates the URL, so copying the address bar and sharing the link reopens the exact same calculation for whoever clicks it.