Intermediate

Power Modulo Calculator — bᵉ mod m

Find the remainder of bᵉ divided by m (written bᵉ mod m) quickly and exactly, no matter how large the exponent.
Any integer
Non-negative integer
Positive integer (the divisor)
bᵉ mod m (remainder)
2

The remainder after dividing bᵉ by m — always in [0, m)

Base (b)
3
Exponent (e)
7
Modulus (m)
5
Result
2
Full cycles (quotient)
437
00.61.31.92.53.13.84.45Remainder sits within [0, m) on the number line
Step by step
  1. 1

    Full power bᵉ

    3 ^ 7 = 2,187
  2. 2

    Full cycles (quotient)

    floor(2,187 ÷ 5) = 437
  3. 3

    Remainder bᵉ mod m

    2,187 − 437 × 5 = 2
Results are estimates for general information only and are not professional advice — always verify important results independently before relying on them. Read the full disclaimer.
Quick answer

How does this calculator work?

Power modulo computes bᵉ mod m — the remainder of bᵉ divided by m. Instead of computing the huge power first, binary exponentiation squares the base and halves the exponent at each step (reducing mod m throughout), running in about log₂(e) steps with exact BigInt arithmetic.

Formula
result = (bᵉ) mod m — computed via binary exponentiation to keep numbers small
How this is calculated

Modular arithmetic asks: after dividing bᵉ by m, what is the remainder? This is written bᵉ mod m and always produces a number in the range 0 to m−1. The operation has a useful "clock" interpretation: numbers wrap around every m steps, so 7 mod 5 = 2 because 7 lands two steps past the 0 mark on a 5-hour clock.

For large exponents, computing bᵉ directly first would produce astronomically large numbers. Instead this calculator uses binary exponentiation (also called exponentiation by squaring): it works through the bits of the exponent from least significant to most, squaring the running base and taking mod m at each step, multiplying into the result only when the current bit is 1. Every intermediate value is bounded by m², so the algorithm is fast regardless of how big e is.

All arithmetic is performed with JavaScript BigInt for exact integer results. A negative base is first normalised into 0..m−1 using ((b mod m) + m) mod m. Constraints: e must be a non-negative integer and m must be a positive integer; fractional inputs are rejected.

Frequently asked questions

For large exponents bᵉ is an astronomically large number — too big to compute or store. Binary exponentiation keeps every value below m² by reducing mod m at every step, finishing in about log₂(e) multiplications instead of e.

"mod m" means the remainder after integer division by m. For example, 17 mod 5 = 2 because 17 = 3 × 5 + 2. The result is always in the range 0 to m−1.

Yes. A negative base is normalised into 0..m−1 before computation using ((b mod m) + m) mod m, so the result is always a non-negative remainder.

Also known as

power modulo calculator
base exponent mod m
a to the b mod n
modular power calculator
remainder of power calculator
clock arithmetic exponent
modpow calculator

APA

TG we-Calculate Editorial Team. (2026). Power Modulo Calculator — bᵉ mod m [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/power-modulo-calculator

Chicago

TG we-Calculate Editorial Team. "Power Modulo Calculator — bᵉ mod m." TG we-Calculate. 2026. https://we-calculate.com/calculator/power-modulo-calculator.

IEEE

TG we-Calculate Editorial Team, "Power Modulo Calculator — bᵉ mod m," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/power-modulo-calculator

BibTeX

@misc{wecalculate_power_modulo_calculator, title = {Power Modulo Calculator — bᵉ mod m}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/power-modulo-calculator}}, year = {2026}, note = {TG we-Calculate} }

Did this calculator help you?