~/boss / power-squared
Fast exponentiation
The Power-Up
Reach 2 to the million in 27 steps instead of a million.
Loading the fight…
How to beat it
Squaring doubles the exponent: 2¹, 2², 2⁴, 2⁸… Write the exponent in binary and read it from the right. Every step squares; when the bit is 1, multiply that square into the result. A million is only 20 bits, so 20 squarings and 7 multiplies.
Now the real boss
Interviews ask for the code. Watch it run, then write it yourself, tested in Python, C++ or Java.
On your phone? Writing code is easier on a laptop: open bossfight.dev/problems/exponentiation there. Sign in with your email to keep your progress on every device.