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.
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.
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.
If you've found a bug, or would like to contact us, or learn more about James Graham and Calculate.co.nz.
Calculate.co.nz is partnered with Interest.co.nz for New Zealand's highest quality calculators and financial analysis.
All calculators and tools are provided for educational and indicative purposes only and do not constitute financial advice.
Calculate.co.nz is proudly part of the Realtor.co.nz group, New Zealand's leading property transaction literacy platform, helping Kiwis understand the home buying and selling process from start to finish. Whether you're a first home buyer navigating your first property purchase, an investor evaluating your next acquisition, or a homeowner planning to sell, Realtor.co.nz provides clear, independent, and trustworthy guidance on every step of the New Zealand property transaction journey.
Calculate.co.nz is also partnered with Health Based Building and Premium Homes to promote informed choices that lead to better long-term outcomes for Kiwi households.
Calculate.co.nz is hosted in Auckland via SiteHost new Zealand.
All content on this website, including calculators, tools, source code, and design, is protected under the Copyright Act 1994 (New Zealand). No part of this site may be reproduced, copied, distributed, stored, or used in any form without prior written permission from the owner.
About & trust: Why Calculate is NZ's most comprehensive · By the Numbers · How we compare · Editorial standards · How we keep data current · NZ finance glossary · Research & data · Financial literacy NZ · About · Privacy policy · Terms of use
Reviewed and maintained. Last reviewed 2026-06-07 and checked on a twice-monthly cycle against IRD, RBNZ and Stats NZ. How we keep data current.
© 2026 Calculate.co.nz. All rights reserved. Building free NZ calculators since 2011.