Let $f$ denote a function. Given that $f(1)=1$, $f(2n)=2f(n)$, and $n\cdot f(2n+1)=(2n+1)\cdot(f(n)+n)$ where $n$ is a positive integer, the question is to prove that every $f(n)$ is an integer.
Though what needs to be proven is intuitively true, I am looking for some rigorous approach. Any idea or hint would be appreciated.
Remark: this problem has been solved thanks to lulu. Please see the two solutions posted below. Nevertheless, any new approach is always welcome.
Induction provides a fairly easy approach to the problem (note that your inductive hypothesis must be something like "$f(n)$ is an integer divisible by $n$").
Here, however, is a different approach:
Claim: $f(n)$ is $n$ times the number of $1's$ in the base $2$ expansion of $n$.
Pf: Let $F(n)$ be $n$ times the number of $1's$ in the base $2$ expansion of $n$, so we want to prove that $F(n)=f(n)$. It is clear that $F(1)=f(1)=1$, so now assume that $n>1$.
Case I: $n$ even. So $n=2m$. Let $k$ be the number of $1's$ in the base $2$ expansion of $m$, so that $F(m)=mk$. Since $n=2m$ has the same binary expansion, with an extra $0$ we see that $F(2m)=2mk=2F(m)$ as desired.
Case II: $n$ odd. So $n=2m+1$. Let $k$ be the number of $1's$ in the base $2$ expansion of $m$, so that $F(m)=mk$. We note that $2m+1$ has exactly one more $1$ in its binary expansion than $m$ does so $F(2m+1)=(2m+1)(k+1)$. It is then easy to confirm that $$mF(2m+1)=m(2m+1)(k+1)=(2m+1)(mk+m)=(2m+1)(F(m)+m)$$
Thus $F(n)$ satisfies the same recursion and initial condition as $f(n)$ so $F(n)=f(n)$ and we are done.