ProgrammingVery hard

Exponentiation by squaring computes x^1000 with how many multiplications at most, counting squarings and the result multiplications?

  1. A. 9
  2. B. 6
  3. C. 15
  4. D. 20

Correct answer: C. 15

There are 9 squarings (floor of log2 1000 is 9) and one multiplication per set bit, of which 1000 has 6, so 15 in total.

More C Programming questions

Exams that ask this topic