Power of 2 Calculator — 2ⁿ
Calculate 2ⁿ for any exponent. See the result, binary representation, nearest power, storage-unit context (KB, MB, GB), and a full reference table from 2⁰ to 2⁶⁴.
Compute aⁿ mod m using modular exponentiation. See the result, step-by-step binary exponentiation, repeated squaring table, and binary decomposition of the exponent.
Blue = 1-bit (multiply), Gray = 0-bit (skip). MSB on left.
| Bit # | Bit | Base (before) | Result (before) | Action | Result (after) | Base (after sq.) |
|---|---|---|---|---|---|---|
| 0 | 1 | 3 | 1 | 1×3 mod 7 | 3 | 2 |
| 1 | 0 | 2 | 3 | skip | 3 | 4 |
| 2 | 1 | 4 | 3 | 3×4 mod 7 | 5 | 2 |
| 3 | 1 | 2 | 5 | 5×2 mod 7 | 3 | 4 |
| k | 3^(2^k) mod 7 | Bar |
|---|---|---|
| 0 | 3 | |
| 1 | 2 | |
| 2 | 4 | |
| 3 | 2 |
Computing large powers modulo a number is fundamental in number theory, cryptography, and competitive programming. Directly calculating aⁿ and then taking the remainder is impractical for large exponents because the intermediate value can be astronomically large. Modular exponentiation solves this efficiently by applying the modulus at every multiplication step, keeping numbers small throughout. The standard algorithm — variously called binary exponentiation, exponentiation by squaring, or the square-and-multiply method — decomposes the exponent n into its binary representation and processes each bit in turn. This Power Modulo Calculator lets you enter any base a, exponent n, and modulus m, then displays the result along with a full breakdown of the binary exponentiation process. A step-by-step table shows the repeated-squaring values and which bits trigger a multiplication into the accumulator. A binary decomposition visual highlights each bit of the exponent. Eight presets cover classic examples including small demonstrations and realistic cryptographic-scale scenarios. Whether you are studying for a number theory exam, implementing RSA, or debugging a competitive-programming solution, the page keeps the algorithm trace and the final residue together.
Power modulo problems are usually about the method as much as the final remainder. This calculator keeps the result next to the exponent's binary form and the repeated-squaring steps so you can see how the modular exponentiation algorithm reached the answer.
That is useful in both math and programming contexts. You can verify a theorem exercise, an RSA-style example, or a competitive-programming implementation without treating the modulus reduction as a black box.
aⁿ mod m via binary exponentiation: write n in binary as bₖbₖ₋₁…b₁b₀. Start with result = 1 and base = a mod m. For each bit from LSB to MSB: if bᵢ = 1 then result = result · base mod m; then base = base² mod m.Result: Result shown by the calculator
Using the preset "2¹⁰ mod 1000", the calculator evaluates the power modulo calculator — aⁿ mod m setup, applies the selected algebra rules, and reports Result with supporting checks so you can verify each transformation.
The calculator reduces the base modulo m, writes the exponent in binary, and then walks through the square-and-multiply process one bit at a time. Each step shows which powers are squared and which ones are multiplied into the accumulator.
Start with the final residue, then compare it with the exponent-in-binary view and the repeated-squaring table. Those supporting outputs help confirm that each multiplication and reduction happened at the right step.
Try one small example manually first, such as 2^10 mod 1000, then compare your bit-by-bit work with the calculator. After that, increase the exponent to see why binary exponentiation scales so much better than naive repeated multiplication.
Last updated:
Modular exponentiation computes aⁿ mod m efficiently without calculating the full value of aⁿ, by taking the modulus at each step.
For large n, aⁿ can have millions of digits — far too large to store or compute. Modular exponentiation keeps every intermediate product below m².
Binary exponentiation decomposes n into its binary bits and uses the identity a²ᵏ = (aᵏ)². This reduces n multiplications to about log₂(n).
Yes. "Square-and-multiply", "binary exponentiation", and "exponentiation by squaring" all refer to the same O(log n) algorithm.
RSA encryption and decryption both rely on modular exponentiation with very large numbers (typically 2048+ bits). The security depends on the difficulty of factoring m.
By convention a⁰ = 1 for any a, so a⁰ mod m = 1 mod m. The calculator handles this case directly.
Calculate 2ⁿ for any exponent. See the result, binary representation, nearest power, storage-unit context (KB, MB, GB), and a full reference table from 2⁰ to 2⁶⁴.
Calculate 10ⁿ for any integer or decimal exponent. See the result, scientific notation, SI prefix, number of digits, and a full reference table from 10⁻¹² to 10¹².
Calculate the Greatest Common Divisor (GCD) of two or more numbers using the Euclidean algorithm. Also known as GCF or HCF.