13. (Norway 1) Let $a, b$ be integers, $1 \leqslant a \leqslant b, M=\left[\frac{a+b}{2}\right]$. Define $f: Z \rightarrow Z$ as $f(n)=\left\{\begin{array}{ll}n+a, & n<M \\ n-b, & n \geqslant M .\end{array}\right.$ Let $f^{1}(n)=f(n) ; f^{1+1}(n)=f\left(f^{1}(n)\right), i=1$, $2, \cdots$. Find the smallest positive integer $k$, such that $f^{k}(0)=0$.
Let $S$ be the set of integers $n$ satisfying $M-b \leqslant n \leqslant M+a-1$, then $f(S) \subseteq S$. For any $k$, if $f^{\mathrm{k}}(0)=0$, according to the definition of $f$, we can assume that there are $r$ times where $f(n)=n+a$ and $s$ times where $f(n)=n-b$, here $r, s \in \mathbb{Z}$. Thus, $k=r+s$, and
$$
a r-b s=0 \text {. }
$$
$$
\text { Let }(a, b)=d, a=a_{1} d, b=b_{1} d, \left(a_{1}\right. \text {, }
$$
$\left.b_{1}\right)=1$. From (1), we know $a, r=b_{1} s$, so $a_{1} \mid s$. Let $s=t a_{1}, t \in \mathbb{Z}$, then $r=t b_{1}$. Therefore,
$$
k=r+s=t\left(a_{1}+b_{1}\right),
$$

hence $k \geqslant a_{1}+b_{1}$.
On the other hand, for $a_{1}+b_{1}(0)$, there exist $r_{1}, s_{1} \in \mathbb{Z}$, such that $a_{1}+b_{1}=r_{1}+s$, and
$$
f^{a_{1}+b_{1}}(0)=a r_{1}-b s_{1} \text {. }
$$

Thus,
$$
f^{a_{1}+b_{1}}(0)=\left(a_{1}-s_{1}\right)(a+b) .
$$

Since $0 \in S, f(S) \subseteq S$, it follows that $f^{a_{1}+b_{1}}(0) \in S$. In $S$, the only number that is a multiple of $a+b$ is 0, hence $f^{a_{1}+b_{1}}(0)=0$.

The above discussion shows that the smallest positive integer $k$ is $a_{1}+b_{1}$, i.e.,
$$
k=\frac{a+b}{(a, b)} .
$$