Number of powers of two needed to be added to the given powers of two to write the (sum of given powers and added powers of two)number of the form $2^k-1$ where $k$ is any integer.
Okay, let me explain the question.
Suppose you are given: $2^0 , 2^1 , 2^2$
Here sum of the numbers $=1+2+4=7=2^3-1$. So, there is no need to add any powers of two :)
Suppose you are given: $2^2 , 2^4 , 2^5$
Here sum of the numbers $=4+16+32=52$ which cannot be written as $2^k-1$ for any $k$.
So, we are adding here $2^0,2^1,2^3$ to the above sum which makes it $63 = 2^6 -1$.
Answer here is $3$ because we are adding here three powers of two ($2^0,2^1,2^3$).
I know that any number can be represented as sum of powers of two. But,can somebody give me an insight how to derive solution for this problem?