Modular Exponentiation Calculator (aᵇ mod m)
Modular exponentiation computes a raised to the power b, reduced modulo m — the core operation behind RSA, Diffie-Hellman and many other cryptographic and number-theory tasks. Computing a^b first and then taking the remainder is impossible for large exponents, so this tool uses fast binary exponentiation (square-and-multiply), reducing modulo m at every step. All arithmetic uses arbitrary-precision big integers, so the result is exact even when the base, exponent or modulus has hundreds of digits. It also reports the modular multiplicative inverse of the base modulo m (the value x with a·x ≡ 1) whenever the base and modulus are coprime. Everything runs locally in your browser — nothing is uploaded.
How to use
- Enter the base (a), the exponent (b) and the modulus (m).
- Read a^b mod m, computed exactly even for very large numbers.
- Check the modular inverse of the base — shown only when gcd(a, m) = 1.
- Try a = 7, b = 256, m = 13 to get 9.
Frequently asked questions
- Why not just compute a^b and take the remainder?
- For large exponents a^b has astronomically many digits and cannot be formed in practice. Square-and-multiply keeps every intermediate value below m², so it stays fast and exact regardless of the exponent's size.
- What is the modular inverse line?
- It is the number x such that a·x ≡ 1 (mod m). It exists only when the base and modulus share no common factor (gcd = 1); otherwise the tool shows that no inverse exists. This is the value used when 'dividing' in modular arithmetic.
- What does an exponent of 0 give?
- a^0 mod m is 1 for any base (and 0 when m = 1). Exponents must be non-negative whole numbers; the base may be negative and is normalised into the range 0…m−1 first.
Related tools
Fraction Calculator — Add, Subtract, Multiply, Divide
Add, subtract, multiply, and divide fractions, mixed numbers, and decimals. Get the reduced fraction, mixed number, decimal, and worked steps.
IBAN Validator
Validate an International Bank Account Number — checks country code, length, and the mod-97 checksum. Supports 75+ countries.
Percentage Calculator
Work out percentages, what-percent, and percent change in one place.
Tip Calculator
Calculate the tip and split the total bill between people.
Tile Calculator
Work out how many floor or wall tiles you need for a room — from its length and width and the tile size, with an adjustable waste allowance and boxes required.
BMI Calculator
Calculate Body Mass Index from height and weight, with a healthy range.