Modular Exponentiation Calculator
Enter integers a, b, and a positive modulus m. The local calculator evaluates aᵇ mod m without floating-point rounding.
A QUICK WALKTHROUGH
How to use this tool
- Enter a, a non-negative b, and m > 0.
- Choose Calculate.
- Read the exact remainder and square-and-multiply trace.
Domain and limits
m must be >0 and b must be an integer ≥0. a may be any signed integer. Inputs are decimal integers with at most 1,000 digits; results use JavaScript BigInt. This is exact modular arithmetic, not a floating-point approximation.
Square-and-multiply
The trace starts with result=1 and base=a mod m. For each binary exponent bit, multiply result by base when the bit is 1, then square the base and halve the exponent. Only residues modulo m are retained.
GOOD TO KNOW
Common questions
Can the exponent be negative?
No. The tool accepts b≥0 and does not compute modular inverses.
Can m be zero?
No. A positive modulus is required.
Are huge integers supported?
Up to 1,000 decimal digits per input, subject to browser resources.