I am asked to create a recursion function that will tell how many ones are in the binary representation of the variable N. So if a user input 4 it would tell them there are one ones. It also says use the fact that this is equal to the number of ones in the representation of N/2 + 1, if N is odd.
Perhaps a point in the right direction would be helpful, I understand the theoretic concept just coding it is my trouble.
Hint: use a mask = 1 ; iterate through each bit using a for loop (int i = 0 ; i < sizeof(int)*8 -1 ; i++)
//bit is one
//bit is zero
Edit : oh i see you need recursion then implement the above loop using a recursive function.