TITLE: Why is it more efficient to compute the modular exponentiation by calculating to the power of two and not three for example?
QUESTION [5 upvotes]: I learned about modular exponentiation from this website and at fast modular exponentiation they calculate the modulo of the number to the power of two and then they repeat this step. Why not calculate to the power of three ?
https://www.khanacademy.org/computing/computer-science/cryptography/modarithmetic/a/fast-modular-exponentiation

REPLY [2 votes]: In order to raise x to the power N - modularly or otherwise - by repeated squaring or cubing, one has to add corrective multiplications to make the final exponent of the result equal to N in base 2 or 3, respectively.  This means one has to extract the base-2 (resp. base-3) digits of N.  The advantage of binary is that, because of our hardware design choices, we already have the base-2 digits of N; extracting them requires only SHIFT and AND instructions.  For base-3 one would have to divide by 3, a significantly more expensive operation.  [this assumes N is a variable input; if N is a pre-chosen constant one can of course precalculate the required steps without performing any divisions]
If we were living in a world where our design choices favored some form of ternary, maybe this question would have been asking why base-2 isn't preferred over base-3.    :-)