Hi, I've been working on topcoder recently and I stumbled upon this question which I can't quite make understand. The question is to find F(n) = f(1)+f(2)+....+f(n) for a given "n" such that f(n) is the largest odd divisor for n. There are many trivial solutions for the answer; however, I found this solution very intriguing.
int compute(n) {
if(n==0) return 0;
long k = (n+1)/2;
return k*k + compute(n/2);
}
However, I don't quite understand how to obtain a recursive relation from a problem statement such as this. Could someone help out?