Question 18
(NOR) Let $a,b$ be natural numbers with $1\le a\le b$, and $M=\left[\frac{a+b}{2}\right]$. Define the function $f:\mathbb Z\to\mathbb Z$ by
$$f(n)=\begin{cases}n+a,&n\lt M,\\n-b,&n\ge M.\end{cases}$$
Let $f^1(n)=f(n)$, $f^{i+1}(n)=f(f^i(n))$, $i=1,2,\ldots$. Find the smallest natural number $k$ such that $f^k(0)=0$.
$$f(n)=\begin{cases}n+a,&n\lt M,\\n-b,&n\ge M.\end{cases}$$
Let $f^1(n)=f(n)$, $f^{i+1}(n)=f(f^i(n))$, $i=1,2,\ldots$. Find the smallest natural number $k$ such that $f^k(0)=0$.