I have a recursion formula $f_{n,k}(0)=n$ and $f_{n,k}(i)=n-f_{n,k}(i-1)\bmod k$ where $n,k$ are positive integers and $k<n$. I can write for example $f_{n,k}(2) = n-(n- n\bmod k)\bmod k $ but I am wondering whether I can write this in a compact form. Playing around with wolframalpha did not really bring me any insights and using small examples like $n=5$ and $k=2$ gave me the impression that there is a periodic behaviour, e.g., $f_{5,2}(2)=5=f_{5,2}(0)$, or $f_{7,3}(2)=7=f_{7,3}(0)$.
Is there anything general that can be said? And can the $\mathrm{mod}$ structure be reduced?