Data Structures & AlgorithmsModerateTCS NQT Digital · Accenture

Problem: Starting with the number 1, double it and add 1 repeatedly. What is the value after the 10th doubling step (starting value 1, 10 operations)?

  1. A. 2047
  2. B. 1023
  3. C. 4095
  4. D. 1024

Correct answer: A. 2047

x → 2x + 1 from 1 gives 2^(k+1) − 1 after k steps, so 2¹¹ − 1 = 2047 after 10. Nine steps give 1023, eleven give 4095, and 2¹⁰ = 1024 forgets the + 1s.

More Coding Interview Problems questions

Exams that ask this topic