TITLE: $f:\Bbb Z\to\Bbb Z$ such that $f(f(n)-2n)=2f(n)+n$ for all $n\in\Bbb Z$
QUESTION [7 upvotes]: Does there exists a function $f:\Bbb Z\to\Bbb Z$ such that $$f(f(n)-2n)=2f(n)+n$$ for all $n\in\Bbb Z$

REPLY [2 votes]: Thanks to drhab, we know that the equation is equivalent to $g(g(n))=5n$ where $g(n)=f(n)-2n$. Now, we can classify all such $g$.
Obviously, $g(0)=0$, while there is no other fixed point $n$ with $g(n)=n$ since that would make $g(g(n))=n$ rather than $5n$. Also, $g$ must be injective since
$$
g(n)=g(m)\implies g(g(n)=g(g(m))\implies 5n=5m\implies n=m.
$$
Let $A_0=\mathbb{Z}\setminus\text{Im}(g)$, i.e. the set of values not in the image of $g$, and $A_k=g(A_{k-1})$ for $k=1,2,\ldots$. As $g(g(n))=5n$, $A_{k+2}=g(g(A_k))=5A_k$. The image of the composition $g\circ g$ is $5\mathbb{Z}$, and so $A_0\cup A_1=\mathbb{Z}\setminus 5\mathbb{Z}$: i.e. $A_0$ and $A_1$ together contain exactly the integers that are not divisible by 5.
If $A_0=\{u_1,u_2,\ldots\}$, then $A_1=\{v_1,v_2,\ldots\}$ where $v_i=g(u_i)$. Furthermore, this makes $g(v_i)=5u_i$. Expanded to $A_{2k}=5^kA_0$ and $A_{2k+1}=5^kA_1$, this makes
$$
g(5^ku_i)=5^kv_i \quad\text{and}\quad g(5^kv_i)=5^{k+1}u_i.
$$
Conversely, any splitting of $\mathbb{Z}\setminus 5\mathbb{Z}$ into to disjoint sets $A_0$ and $A_1$ and a one-to-one map $g:A_0\rightarrow A_1$ (defining $v_i=g(u_i))$ as above) will extend uniquely to a map $g:\mathbb{Z}\rightarrow\mathbb{Z}$ with $g(g(n))=5n$.
To summarise, any function $g:\mathbb{Z}\rightarrow\mathbb{Z}$ with $g(g(n))=5n$ can be defined by selecting two series $u_1,u_2,\ldots$ and $v_1,v_2,\ldots$ so that every integer not divisible by 5 appears exactly once in one of the two series, and then define
$$
g(5^ku_i)=5^kv_i \quad\text{and}\quad g(5^kv_i)=5^{k+1}u_i
\quad\text{for}\quad k=0,1,\ldots.
$$