I am writing a program and I need help with a part of it.
Need a recursive function that returns the number of 1's in the binary representation of N. I am using the fact that this is equal to the number of 1's in the representation of N/2, plus 1, if N is odd.
Can anyone assist me. email@example.com
Answer these 2 questions and you should be able to write it yourself....
1) What is the base case?
2) How do I simplify towards the base case.
The structure of a recursive function is normally like this...
int func( int param)
// this is where the real work of the function is...
// call func again with simpler terms nearer to the base case.