IP331.com | Online Tools
HomeNumber Theory ToolsModular Exponentiation Calculator

Modular Exponentiation Calculator

Compute a^b mod m using repeated squaring

base a
exponent b
mod m

Modular Exponentiation Formula

Compute a^b mod m
(a x b) mod m = ((a mod m) x (b mod m)) mod m
Repeated squaring reduces after every step

Modular exponentiation finds the remainder of a power under a modulus. Repeated squaring avoids huge intermediate values by reducing each squared power modulo m before continuing.

Use a nonnegative exponent and modulus at least 2. Extremely large inputs may exceed normal browser integer precision.

How Modular Exponentiation Works

Modular exponentiation rewrites a large power as a product of squared powers. Each step is reduced modulo m, which makes the calculation fast and suitable for cryptography and number theory.

Base Reduction

Start by replacing a with a mod m.

Repeated Squaring

Square powers while reducing after each multiplication.

Exponent Bits

Multiply only the powers needed by the exponent.

Verification

The final answer is the same remainder as direct exponentiation would give.

Example: For 7^128 mod 13, repeated squaring keeps reducing powers modulo 13 and returns the final remainder without expanding 7^128.

Applications of Modular Exponentiation

RSA Encryption Diffie-Hellman Primality Tests Modular Arithmetic Contest Math

Frequently Asked Questions

What is a modular exponentiation calculator?
It computes a^b modulo m without expanding the huge power directly. The result is the remainder after division by m.
What formula does modular exponentiation use?
It uses repeated squaring: reduce the base modulo m, square repeatedly, and multiply selected powers according to the exponent.
How do I use this modular power calculator?
Enter the base, exponent, and modulus, then calculate. The tool returns a^b mod m with a short derivation.
Why not calculate a^b directly first?
Large powers grow extremely fast. Reducing after each multiplication keeps the numbers small and exact for modular arithmetic.
Where is modular exponentiation used?
It is used in RSA encryption, Diffie-Hellman key exchange, primality tests, modular arithmetic, and contest math.

More Number Theory Tools

Free online calculators and tools covering mathematics, unit conversion, text processing, and daily life. Accurate, fast, mobile-friendly, and completely free to use.

© 2026 IP331.com — Free Online Tools. All rights reserved.

About · Contact · Privacy Policy · Cookie Policy · Terms of Use · Disclaimer · Sitemap