$11 \cdot 14 n$ is a non-negative integer. Given $f(0)=0, f(1)=1, f(n)=$ $f\left(\left[\frac{n}{2}\right]\right)+n-2\left[\frac{n}{2}\right]$. Determine $f(n)$. Find the maximum value of $f(n)$ for $0 \leqslant n \leqslant 1991$. (Here $[x]$ denotes the greatest integer not exceeding $x$)
(Japan Mathematical Olympiad, 1991)
\[ \text{Solution:} \] Express \( n \) as a binary number:
\[
n=\left(\overline{a_{k} a_{k-1} \cdots a_{2} a_{1}}\right)_{2} .
\]

Here \( a_{i}=0 \) or \( 1, i=1,2, \cdots, k \), then
\[
\begin{aligned}
& {\left[\frac{n}{2}\right]=\left(\overline{a_{k} a_{k-1} \cdots a_{2}}\right)_{2} . } \\
f(n) & \left.=f\left(\overline{a_{k} a_{k-1} \cdots a_{2} a_{1}}\right)_{2}\right) \\
& =f\left(\left[\frac{n}{2}\right]\right)+n-2\left[\frac{n}{2}\right] \\
& =f\left(\left(\overline{a_{k} a_{k-1} \cdots a_{2}}\right)_{2}\right)+a_{1} \\
& =f\left(\left(\overline{a_{k} a_{k-1} \cdots a_{3}}\right)_{2}\right)+a_{2}+a_{1} . \\
& =\cdots \\
& =a_{k}+a_{k-1}+\cdots+a_{2}+a_{1} .
\end{aligned}
\]

Thus, \( f(n) \) is equal to the number of 1s in the binary representation of \( n \).
Since \( 0<2^{10}-1<1991<2^{11}-1 \),
\( n \) can have at most 11 binary digits, but \( n \) can have up to 10 ones, but not 11 ones.
Therefore, the maximum value of \( f(n) \) is 10.