Calculators
Modular Exponentiation Calculator
Calculate a power modulo a positive integer using exact arithmetic and fast repeated squaring, entirely in your browser.
Calculate a^e mod m using repeated squaring. Enter a signed base, a non-negative exponent and a positive modulus, each up to 100 digits. Calculations stay in your browser.
How modular exponentiation works
Modular exponentiation finds the non-negative remainder of a raised to e divided by m. Repeated squaring reduces each product modulo m, avoiding construction of the enormous full power. Each round halves the remaining exponent, so even a 100-digit exponent needs only about 333 rounds. For example, 2^10 mod 1000 = 24; a negative base is normalized first, so (-2)^3 mod 5 = 2. An exponent of zero uses the empty-product convention a^0 = 1, including 0^0 for this modular operation. Modulus 1 always gives zero. Enter up to 100 digits per input, with an optional minus sign; the exponent must be non-negative and the modulus positive. Surrounding whitespace and leading zeros are accepted; decimals, plus signs, separators and scientific notation are rejected. Negative exponents require modular inverses and are outside this tool’s scope. Exact BigInt arithmetic runs locally without uploading or storing inputs.
Frequently Asked Questions
Everything you need to know about this tool, how it works, and privacy.
How can this handle very large exponents?
Repeated squaring halves the exponent each round and reduces intermediate products modulo the modulus. It never constructs the full power.
Can the base be negative?
Yes. The base is normalized to a non-negative residue before exponentiation. For example, (-2)^3 mod 5 is 2.
What happens with exponent zero or modulus one?
Exponent zero uses a^0 = 1, including 0^0 by the empty-product convention. The remainder modulo 1 is always zero.
Are negative exponents supported?
No. Use a non-negative exponent. Negative exponents require a modular inverse, which does not exist for every base and modulus.
Are my inputs private and the results exact?
Yes. All calculations use browser BigInt arithmetic for inputs of up to 100 digits each, without uploading or storing them.