Multiple choice technology

How many multiplications do you need to perform if you use Repeated Squaring technique to calculate n^1000. (Ignore the problem of storing such a large number in variable assume you can store infinitly large number in basic data types)

  1. 99

  2. 119

  3. 6

  4. 14

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Repeated squaring (exponentiation by squaring) computes n^1000 by decomposing the exponent into binary. 1000 in binary is 1111101000 (base-2), which has 10 bits requiring 9 squarings, and Hamming weight of 6 ones requiring 5 extra multiplications. Total: 9 + 5 = 14 multiplications. This is dramatically fewer than 1000 for naive multiplication.