How it is calculated
The exponent is not negative. A negative base is first reduced to a remainder from 0 up to the modulus.
Result = base ^ exponent mod modulus
Where the numbers come from
- Base
- Exponent
- Modulus
Example
2^10 mod 1000 = 1024 mod 1000 = 24.
Questions
Why not compute the power directly?
Already 2^100 is a huge number. Multiplying step by step modulo n stays small.
Modulus of 1?
The remainder of any power modulo 1 is 0.
A power of zero?
It returns 1, including for a base of zero in this calculator.