There are essentially two steps to the problem, given
void foo ( int num );
1. do something with num % 2
2. call foo ( num / 2 );
Changing the order of those two steps changes what happens - feel free to experiment.
Oh, and you also need something to decide when to stop recursing otherwise you'll just go on until you run out of stack.
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Offline 7,164 posts
since Dec 2005