This was a problem asked in a coding competition at CodeChef and I asked it before on math stack exchange but unknowingly during the competition as I was not aware of the norms before. As the contest is now over and I still don't get how to do it,I want to find the solution to this and how to solve this recursive equation. Let $f(x)=y$ be a function that takes input $x$ and returns $y$.
$f(x) = (x/2)+f(x/2)$ if $x$ is even.
$f(x) = (x*(x-1))/2$ if $x$ is odd.
$f(0) = 0$ How to find all the values of $x$ for a given $y$ ? For eg: for $y=3$ $x$ can be $3$ and $4$
Hint: Write $x = 2^m\cdot n$, where $m, n$ are natural numbers and $n$ is odd.