Modular Exponentiation Calculator NZ
This calculator computes modular exponentiation, a base raised to an exponent and then reduced modulo a number, which is written as base to the power exp, mod m. This operation is the computational heart of modern cryptography, including the RSA and Diffie-Hellman algorithms that secure the internet, as well as a fundamental tool in number theory. The challenge is that the exponent can be enormous, and raising a number to a huge power would create a value with thousands of digits, far too large to handle directly. The clever solution is fast modular exponentiation, also called exponentiation by squaring, which keeps the numbers small by taking the modulus at every step and squaring its way up through the exponent's binary representation. This means even astronomically large exponents are handled almost instantly. This tool implements it. You enter the base, the exponent, and the modulus, and the calculator returns the result, the remainder when the base raised to the exponent is divided by the modulus, along with the inputs for reference. It uses big-integer arithmetic internally, so the result is exact even for large values. The results update as you type. Use it for cryptography study and exercises, for number theory, for checking modular arithmetic, or for understanding how public-key encryption performs its calculations. The method works by writing the exponent in binary and repeatedly squaring the base modulo m, multiplying the running result whenever a binary digit is one, so the number of operations grows only with the number of digits in the exponent, not its size. This efficiency is what makes public-key cryptography practical. The modulus must be a positive whole number, and the result is always a non-negative integer less than the modulus.
Uses fast exponentiation by squaring with big-integer arithmetic, so very large exponents compute instantly. The result is a non-negative integer less than the modulus.
Learn more about maths and statistics on Understand.co.nz, free lessons for New Zealanders.
How it works
Rather than computing the full power, the calculator writes the exponent in binary and works up through it, squaring the base modulo the modulus at each step and multiplying the running result whenever a binary digit is one. Taking the modulus at every step keeps the numbers small, so even huge exponents are handled in a number of steps equal to the exponent's digit count.
Worked example
To compute 7 to the power 128, modulo 13, the calculator squares its way up: 7 squared is 49, which is 10 mod 13; squaring and reducing repeatedly through the powers of two that make up 128 gives a final result of 3. So 7 to the power 128, mod 13, equals 3, computed without ever forming the gigantic full power.
Related calculators
- Modulo Calculator: remainder.
- Exponent Calculator: powers.
- Prime Factorisation: prime factors.
- GCD & LCM: common factors.
- Euler Totient: phi(n) for Euler's theorem.