Home / Calculators / Modular Exponentiation Calculator
Calculators

Modular Exponentiation Calculator

Enter a base, non-negative exponent, and positive modulus to compute modular powers with repeated-squaring steps.

Modular power
—
Repeated squaring keeps intermediate values reduced modulo n.
a^b mod n
Repeated-squaring steps
Bit stepExponent stateCurrent powerMultiply?Result

This is exact integer modular arithmetic. It is useful for math/programming exercises, but this page is not a cryptographic protocol implementation or key-management system.

Modular Exponentiation: Fast-Power Proof & Trace

Compute a^b mod n and verify it with binary exponentiation, exponent-bit counts and a copyable square-and-multiply trace.

How to use this Modular Exponentiation Calculator

Enter a base, non-negative exponent, and positive modulus. The calculator uses exact BigInt repeated squaring to compute a^b mod n without constructing the full power.

Definitions and limits

The step table explains modular exponentiation for math and programming work. It is not a cryptographic protocol implementation, key generator, or security audit tool.

Practical guide and verification

Read the expression as repeated modular reduction

The goal is a^b mod n, not to construct a^b as one enormous integer first. Square-and-multiply repeatedly reduces intermediate values modulo n, keeping the computation practical even when the exponent is large.

Require a positive modulus

A modulus of zero has no valid remainder operation, and cryptographic or number-theory conventions normally use a positive modulus. If the base is negative, the canonical nonnegative residue should still lie from zero through n minus one.

Verify small cases by ordinary arithmetic

For a manageable exponent, compute the power independently and divide by the modulus to check the remainder. For larger exponents, use the displayed square-and-multiply rows to confirm each squaring or multiplication is followed by reduction.

Distinguish modular exponentiation from a cryptographic proof

The arithmetic is used inside RSA, Diffie-Hellman, primality tests, and many algorithms, but a correct residue does not validate a key, prove a number prime, or make an arbitrary protocol secure. Those tasks require additional rules.

Preserve exact integers when copying evidence

These calculations are integer operations. Avoid spreadsheet or programming environments that silently round very large integers to floating point. Copy the exact base, exponent, modulus, and residue when reproducing the result elsewhere.

Search by task, tool name, or category. Press Esc to close.
Start typing to find a tool.