How this calculation works
Repeated squaring builds powers a, a², a⁴ and so on. The binary digits of the exponent select which of those remainders are multiplied. Reducing after every step keeps the calculation bounded.
a^e mod m, with each squaring reduced modulo mA worked example
3^13 mod 17 is 12: 13 = 8 + 4 + 1, so multiply the selected squared remainders and reduce modulo 17.
Good to know
Non-negative base and exponent, modulus at least 2, each at most one billion. This is educational arithmetic and does not generate or protect cryptographic keys.
Reference: MIT OpenCourseWare: Theory of Numbers lecture notes (opens in a new tab) ↗
Keep the remainder at every squaring
Computing 3^13 outright is possible, but the same method also handles exponents far too large for a normal floating-point power. Write 13 as 8+4+1, build 3^1, 3^2, 3^4 and 3^8 modulo 17, and multiply only the selected remainders.
Each table row states its power of two and whether it contributes. A skipped row still matters because squaring it generates the next row. The final remainder is 12, whereas the unrestricted power is a different quantity.
The multiplicative order calculator finds the shortest coprime power cycle; this page evaluates one chosen exponent.
Cycles connect to multiplicative order
A power remainder can reveal a cycle when base and modulus are coprime. The multiplicative order calculator finds the first exponent returning remainder one. This page answers one specified exponent instead of searching for that cycle.
For a modulus of 17, residues live between 0 and 16. The power calculator gives the ordinary full power when its result fits; reducing a power modulo 17 answers a different, repeated-wrap question.
Arithmetic demonstration is not encryption
Modular exponentiation appears in cryptography, but a small publicly chosen base, exponent and modulus do not create secure keys. This calculator makes no claim about key generation, randomness or protection against attacks.
An exponent of zero gives remainder 1 for any modulus above one, including a base of zero in this conventional modular-arithmetic setting. The modulus cannot be zero or one here.
A few questions, answered
Why do intermediate remainders stay small?
Every multiplication is followed by reduction modulo the entered modulus.
Does changing the exponent by the modulus preserve the result?
Not generally. Power cycles depend on the base and modulus, not simply on the modulus.
Can I enter a negative exponent?
No. Negative exponents require a modular inverse when one exists and are outside this tool’s stated scope.