What wrong in this code
hey the answer is simply the number of sets bit in the given number and your code doesnt calculate that thats why it is giving wrong answer.
Correct code:
can you explain me question as i don.t understand why to count set bit
@Adityakumar3112 it is mentioned in the question that you have reach a number n and you can only add numbers that are in power of 2 tell the minimum numbers you should add. When a number is represented in their binary representation where 1 is present it means that that positional power of 2 must be added to make this number, thats why we count the number of 1’s in the number