TITLE: Functional equation $f(f(x))=2x$ on $\mathbb{Z}_{>0}$
QUESTION [6 upvotes]: I have this functional equation:
$$f(f(x))=2x$$
with $f: \mathbb{Z}_{>0}\rightarrow \mathbb{Z}_{>0}$. And I want to know if it is possible to list all solutions. 
I already know that $f(2x)=2f(x)$, further, if $f(1)=c$, then $f(2^kc)=2^{k+1}$ by induction and $f(2^k)=2^kc$ but that doesn't really give anything. I have attempted, but I think there is a clever step I don't see. Also, since $f \circ f$ is injective, $f$ must be injective. 
I actually suspect that there either no solutions or uncountably many, of which most aren't nice functions.

REPLY [7 votes]: An example function satisfying this property is the function $f$ defined by 
$$
f((4k+1)2^i) = (4k+3)2^i\\
f((4k+3)2^i) = (4k+1)2^{i+1}
$$
Fundamentally, all answers are at least somewhat similar to this.  You should try to prove that for all odd $x$, $f(x)$ is either odd or twice an odd number, in which case $x = f(f(x)/2)$.  You can then describe all solutions as indexed by partitions of the odd numbers into ordered pairs $(a_1, b_1), (a_2, b_2), \ldots$, where 
$$f(a_i2^j ) = b_i2^j\\
f(b_i2^j) = a_i2^{j+1}$$ 
 This leads to an uncountable number of solutions.