Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to find the number of multiplications to calculate $x^n$. I have arrived at this:

$$M(n) = \begin{cases} - 1 + M\left(\frac{n}{2}\right) & \text{if $n$ even}\\ - 2 + M\left(\frac{n-1}{2}\right) & \text{if $n$ odd} \end{cases} $$

with initial conditions $M(1) = 0$ and $M(2) = 1$.

so how do I solve this? Thanks for any help!

share|cite|improve this question
There is an easy answer in terms of the binary representation of $n$. I am sure you can work it out given this hint. – André Nicolas Jan 7 '13 at 1:01

Sequence A014701 in the OEIS:

share|cite|improve this answer

But that is not always the best. Knuth has a very detailed (as always) discussion of this problem. iirc, 15 is the first value at which your method is not the best.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.