Toolstia / Modular exponentiation calculator
Modular exponentiation calculator
Modular exponentiation finds the remainder of a big power without computing the power itself. Enter a base, an exponent and a modulus with up to 1500 digits and get the result at once.
This uses square and multiply, which handles exponents with hundreds of digits quickly by reducing after every step. A negative exponent is allowed when the base and modulus share no common factor, and it uses the modular inverse. Numbers can have up to 1500 digits.
How it works
- Enter the base, exponent and modulus.
- Read the result.
- Copy it, or look at the number of squarings used.
Square and multiply
The exponent is read bit by bit. The base is squared at each step and multiplied in when the bit is 1, always reducing by the modulus, so the numbers stay small.
Negative exponents
A negative exponent works when the base and modulus share no common factor. The tool uses the modular inverse.
Uses
RSA encryption, Diffie-Hellman key exchange, primality tests and number theory homework.
Big numbers
It uses exact whole number arithmetic, so there is no rounding at any size.
Questions
Is my data sent anywhere?
Everything happens in your browser, and nothing you enter is sent anywhere.
Is the result always positive?
Yes. The result is between 0 and the modulus minus 1, even for negative bases.
What if the modulus is 1?
Every number is 0 modulo 1, so the result is 0.