Find the number of functions $f(x)$ from nonnegative integers to nonnegative integers so that $f(f(n)) = n+2022$ for every nonnegative integer n.
Let $a_0 = f(0)$ and let $a_n = f(a_{n-1})$ for $n\ge 1$. Then $a_{n} - a_{n-2} = 2022$ for every $n\ge 2$. The characteristic equation of the corresponding homogeneous recurrence is $x^2 - 1,$ which has roots $\pm 1.$ Also, $b_n = 1011 n + b$ satisfies the inhomogeneous recurrence $b_n - b_{n-2} = 2022$ for any integer $b$. So $a_n = A(-1)^n + 1011 n + B$ for some integers $A,B$ and all $n$. We must ensure that $a_n$ is always nonnegative. We must have $a_0\ge 0\Rightarrow A \ge -B.$ Also, $a_1\ge 0\Rightarrow -A +1011 + B \ge 0, a_2\ge 0\Rightarrow A +2022 + B\ge 0.$ In general, for all $n=2k+1> 0$, $B\ge A-1011 n$ and for all $n=2k\ge 0, A\ge -B-1011n$. To satisfy both of these inequalities, it suffices to have $B\ge A-1011$ and $A\ge -B\Rightarrow B\ge -B-1011\Rightarrow 2B\ge -1011.$ So $B$ is at least $-505.$ Though I'm not sure how to determine what $f(n)$ can be. Clearly $f(n) = n+1011$ solves the functional equation and $f(0)$ cannot be zero, so it must be positive. If there exists $n$ so that $f(n) = n$, then we get $n=n+2022$ by plugging this n into the given equation, which is a contradiction. Hence $f$ has no fixed points.