22 Use a sequence to traverse all integer points on the complex plane: Let $a_{0}=0, a_{1}=1$, then proceed in a counterclockwise direction, one step at a time. Also, let $a_{n+1}-a_{n}=\mathrm{i}^{f(n)}$, where $\mathrm{i}$ is the imaginary unit. Find the simplest unified expression for $f(n)$.
22 Since $\mathrm{i}^{4}=1$, $f(n)$ should be a congruence modulo 4. To find the pattern, we first seek
$$
\begin{array}{l} 
f(n)= 0,1,2,2,3,3,4,4,4,5,5,5, \cdots, \overbrace{2 k, \cdots, 2 k}^{k+1 \uparrow}, \\
\overbrace{2 k+1, \cdots, 2 k+1}^{k+1 \uparrow}, \cdots
\end{array}
$$

For the smallest $n$ such that $f(n)=2 k$, we have
$$
n=2 \times 1+2 \times 2+\cdots+2 \times k=k(k+1) .
$$

Therefore,
$$
f(n)=\left\{\begin{array}{ll}
2 k, & \text { when } k(k+1) \leqslant n<(k+1)^{2}, \\
2 k+1, & \text { when }(k+1)^{2} \leqslant n<(k+1)(k+2),
\end{array}\right.
$$

That is, $f(n)=l$. When $l$ is even, $k=\frac{l}{2}$, so
$$
\frac{l}{2}\left(\frac{l}{2}+1\right) \leqslant n \leqslant\left(\frac{l}{2}+1\right)^{2}-1,
$$

which means
$$
l(l+2) \leqslant 4 n \leqslant(l+2)^{2}-4,
$$

or equivalently,
$$
(l+1)^{2} \leqslant 4 n+1 \leqslant(l+2)^{2}-3<(l+2)^{2} .
$$

When $l$ is odd, $k=\frac{l-1}{2}$, so
$$
\left(\frac{l+1}{2}\right)^{2} \leqslant n \leqslant \frac{l+1}{2} \frac{l+3}{2}-1,
$$

which means
$$
(l+1)^{2} \leqslant 4 n \leqslant(l+1)(l+3)-4,
$$

or equivalently,
$$
(l+1)^{2}<(l+1)^{2}+1 \leqslant 4 n+1 \leqslant(l+2)^{2}-5<(l+2)^{2} .
$$

In summary, $l=[\sqrt{4 n+1}]-1$. Therefore,
$$
f(n)=[\sqrt{4 n+1}]-1 \quad(\bmod 4) \text {. }
$$