Can anyone explain with the help of an example

First of all, what is your doubt?

you didn’t get any idea to solve this question or you don’t understand the question?

The question asks for the minimum absolute difference between a number N and a number A, which is actually a power of 2. Since the minimum difference has been asked, it is obvious that A is the closest number to N that is a power of 2. Do not forget that the number A could be either less than, greater than or even equal to N.

For example, if N=5, the nearest power of 2 is 4. For N=3, the nearest powers of 2 are 2 and 4. For N=8, the nearest power of 2 is 8 itself. For N=9, the nearest power of 2 is 8.

2 Likes