About this tool: Modular Exponentiation
Calculate integer powers modulo a positive modulus using BigInt, including negative bases and very large exponents.
a, e and m are integers; e must be nonnegative and m positive. Binary exponentiation reduces intermediate products modulo m and keeps integer precision with BigInt. A negative base is normalized to its nonnegative residue. The result for exponent zero is 1 mod m, including 0 when m=1.
How the calculation works
Worked example
| a | 7 |
| e ≥ 0 | 128 |
| m > 0 | 13 |
7¹²⁸ mod 13 = 3
Questions and answers
What does this tool do?
Calculate integer powers modulo a positive modulus using BigInt, including negative bases and very large exponents. a, e and m are integers; e must be nonnegative and m positive. Binary exponentiation reduces intermediate products modulo m and keeps integer precision with BigInt. A negative base is normalized to its nonnegative residue. The result for exponent zero is 1 mod m, including 0 when m=1.
What affects precision and input format?
BigInt preserves integer precision. The exponent is nonnegative and the modulus positive.
Where are the calculations performed?
The calculation runs in your browser. You can use the tool without installing software.
Comments (0)
Share your thoughts — please be polite and stay on topic.
Log in to comment