Skip to main content
HSCalculadora

Modular Exponentiation Calculator

Compute (base^exponent) mod m efficiently.

Results update as you type.

Result (base^exp mod m)
—

How it works

Modular exponentiation computes a base raised to an exponent, then reduced modulo a number, and this calculator does it efficiently even for large exponents. You enter the base, the exponent, and the modulus, and it returns the result of the base to the power of the exponent, modulo the modulus. Computing this naively by first raising the base to the full power would produce an astronomically large number for even modest exponents, so the calculator uses exponentiation by squaring, repeatedly squaring the base and taking the remainder at each step. This keeps every intermediate value small while producing the correct final remainder, and it is dramatically faster, needing only about as many steps as the number of bits in the exponent. Modular exponentiation is a cornerstone of modern cryptography: it is the core operation in RSA encryption, Diffie-Hellman key exchange, and many other public-key systems, where large numbers are raised to large powers modulo a large number. It also appears in number theory, primality testing, hashing, and pseudorandom number generation. This calculator is useful for students learning number theory and cryptography, for verifying computations, and for exploring modular arithmetic. The base can be any integer (including negative, which is normalized), the exponent must be non-negative, and the modulus must be positive. Enter the base, exponent, and modulus to compute the modular power.

Formula

result = (base ^ exponent) mod modulus

Modular exponentiation computes the remainder when a base raised to an exponent is divided by a modulus. The calculator uses fast exponentiation by squaring, taking the modulus at each step, so it handles large exponents without computing the astronomically large full power.

Source:Number theory

We review all our tools from time to time to ensure accuracy.

Worked example

Base:3Exponent:13Modulus:7
3^13 = 1,594,323; 1,594,323 mod 7 = 3.

How to use this calculator

  1. 1

    Enter your values

    Enter base, exponent and modulus.

  2. 2

    Adjust the options

    Fine-tune any options to match your situation.

  3. 3

    Read your result

    Result (base^exp mod m) updates instantly as you type — no button to press.

Frequently asked questions

What is modular exponentiation?

Modular exponentiation is computing the remainder when a base raised to an exponent is divided by a modulus, written as base to the power exponent, mod m. It is a fundamental operation in number theory and cryptography, where it must be computed efficiently for very large numbers without ever forming the full, enormous power.

How does fast exponentiation work?

Exponentiation by squaring repeatedly squares the base and multiplies selected results together based on the binary representation of the exponent, taking the modulus at every step. This keeps intermediate numbers small and requires only about as many multiplications as the exponent has bits, making it vastly faster than multiplying the base by itself exponent times.

Why is modular exponentiation important in cryptography?

It is the core computation in public-key cryptography systems like RSA and Diffie-Hellman, which raise large numbers to large powers modulo a large number. The security of these systems relies on modular exponentiation being fast to compute but the reverse operation (the discrete logarithm) being extremely hard, protecting encrypted data and key exchanges.

Why not just compute the full power then take the modulus?

Raising a base to a large exponent produces a number with an astronomical number of digits, far too large to store or compute practically. For example, a modest cryptographic exponent would create a number with thousands of digits. Taking the modulus at each squaring step keeps every value small, which is why the fast method is essential.

What are the input requirements?

The base can be any integer; a negative base is normalized into the valid range modulo m. The exponent must be a non-negative integer, since negative exponents require modular inverses, a different operation. The modulus must be a positive integer. Given valid inputs, the calculator returns the exact remainder efficiently, even for large exponents.