Mathematics

Modular Exponentiation

Calculate integer powers modulo a positive modulus using BigInt, including negative bases and very large exponents.

01Input and settings

The calculation runs in your browser. You can use the tool without installing software.

02Result

Waiting for input
Waiting for input

Enter your values or load the example to see the result here.

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

aᵉ mod m; integer arithmetic

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.

No comments yet. Leave a comment — share your opinion!

To leave a comment, please log in.

Log in to comment