0

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?

emacs drives me nuts
  • 10,390
  • 2
  • 12
  • 31
Jfischer
  • 1,239
  • Modulo $k$ you are just oscilating between two values $n$ and $0$, so except first value (where you do not apply $\bmod$), it will be just $n \bmod k$ ($i$ even) or $n-n \bmod k$ ($i$ odd). – Sil Sep 09 '22 at 14:02
  • You can show the above also by proving that $(n- n\bmod k)\bmod k=0$ – Sil Sep 09 '22 at 14:31

0 Answers0