我的解法如下
f(1)=1, f(2)=2 ,
f(n)={ 若 n=2^x: 2*f(n/2)+( n/2-1 ) ,
否則 找最大的 k=2^y<n : f(k)+f(n-k)+(n-k) }
例
f(3) = f(2)+f(1)+(3-2) = 2+1+1 = 4
f(4) = 2*f(2) + (2-1) = 2*2+1 = 5
f(5) = f(4)+f(1)+(5-4) = 5+1+1 = 7
f(6) = f(4)+f(2)+(6-4) = 5+2+2 = 9
f(7) = f(4)+f(3)+(7-4) = 5+4+3 = 12
f(8) = 2*f(4) + (4-1) = 2*5+3 = 13
...
f(12) = f(8)+f(4)+(12-8) = 13+5+4 = 22
...
f(16) = 2*f(8) + (8-1) = 2*13+7 = 33