If $f(f(x))$ is linear, is $f(x)$ linear? If f(x) is closed on the set of natural numbers? If I have a function defined on the natural numbers $\mathbb Z_{>0}$, does $f(f(x))=ax+b$ imply that $f(x)=rx+q$, where $a,b,r,q$ are naturals? This came to mind in the context of a different problem, but I don't know where to start.

No: consider the function $f$ that swaps every odd natural number with its successor. Then $f\circ f=id$ but $f$ is not monotone.
