Problem
Let $k$ be a positive integer. Find all functions $f :\mathbb{N_0} \to \mathbb{N_0}$ such that $$f(f(n)) = n + k$$ for any $n \in \mathbb{N_0}$.
My approach
I tried substitution. Here is what I got:
$$f(f(n+1))-f(f(n))=1 \tag{1}$$
$$f(n+k)=f(f(f(n)))=f(n)+k \tag{2}$$
However, I don't know how to use them to proceed further.
As suggested in the comments, here is what I got for $k=1$ and $k=2$.
For $k=1$,
Using $(2)$ we have $$f(n+1)=f(n)+1$$
Now let $f(0)=c$ such that $c \in \mathbb{N_0}$. Then, we have $f(n)=n+c$. Then $$f(f(n))=n+2c=n+1$$
which is a contradiction and this leads there is no solution for $k=1$.
For $k=2$, similar works lead that $f(n)=n+1$ is the only solution.
So, I need a generalized solution to the problem.
(Disclaimer: It's late, so I might have made an error here. However, I believe this is correct.)
Hint / Steps: (If you're stuck, show what you've tried.)
Let $ a_k$ denote $ a \mod{k}$.
Let $ [k] = \{0, 1, \ldots, k-1\}$.