What Is the Power Mod Calculator?
The Power Mod Calculator computes (baseexponent) mod m — the remainder left after raising a base to a power and dividing by a modulus. This single operation, called modular exponentiation, is everywhere in number theory and cryptography: it powers RSA encryption, Diffie-Hellman key exchange, primality tests, and hash functions. Computing it directly (calculating the giant power first, then taking the remainder) is impossible for large exponents, so we use a fast algorithm instead.
How to Use It
Enter three whole numbers: the base, the exponent (zero or positive), and the modulus m (a positive integer greater than 1). Press calculate and the tool returns the result in the range 0 to m−1. Negative bases are reduced into the proper non-negative residue automatically.
The Formula Explained
The calculator evaluates:
$$\text{result} = \text{Base}^{\text{Exponent}} \bmod \text{Modulus}$$Rather than building the enormous number baseexponent, the calculator uses square-and-multiply (also called binary exponentiation). It reads the exponent in binary. Starting with a result of 1, it repeatedly squares the base modulo m; whenever the current binary digit of the exponent is 1, it multiplies that squared value into the running result, again reducing modulo m. Because every intermediate number stays smaller than \(m^2\), the computation is fast even for exponents with hundreds of digits.
Worked Example
Compute \(7^{256} \bmod 13\). The order of 7 modulo 13 divides 12, and \(7^{12} \equiv 1\). Since \(256 = 12 \times 21 + 4\), we get
$$7^{256} \equiv 7^{4} = 2401 \equiv 9 \pmod{13}$$So the answer is 9 — found instantly here without ever forming the 217-digit number \(7^{256}\).
FAQ
What if the modulus is 1? Every integer is congruent to 0 modulo 1, so the result is 0.
Can the exponent be 0? Yes. Any base to the power 0 equals 1, so the result is 1 mod m (which is 1 when m > 1).
Why not just compute the power directly? For large exponents the intermediate number would have astronomically many digits and overflow. Modular reduction at every step keeps values small and the method efficient.