5. Let $f: N \rightarrow N$, and for all positive integers $n$, $f(n+1)>f(n), f(f(n))=3n$. Then the value of $f(1997)$ is ( ).
(A) 1997
(B) 1268
(C) 3804
(D) 5991
5. (C).

From the given conditions, we can prove: $f(1)=2, f(2)=3$,
$$
f(3 n)=f[f(f(n))]=3 f(n) .
$$

From (1) and $f(1)=2, f(2)=3$, we get
$$
f\left(3^{n}\right)=2 \cdot 3^{n}, f\left(2 \cdot 3^{n}\right)=3^{n+1} .
$$

Notice that there are $3^{n}-1$ natural numbers between $2 \cdot 3^{n}$ and $3^{n+1}$, and there are also $3^{n}-1$ natural numbers between $3^{n}$ and $2 \cdot 3^{n}$. By the monotonicity of $f$, we have
$$
f\left(3^{n}+m\right)=2 \cdot 3^{n}+m, 0 \leqslant m \leqslant 3^{n}, n=0,1,2,
$$
$\cdots$. Furthermore,
$$
f\left(2 \cdot 3^{n}+m\right)=f\left(f\left(3^{n}+m\right)\right)=3\left(3^{n}+m\right) .
$$

Since $1997=2 \cdot 3^{6}+539$, we have
$$
f(1997)=3\left(3^{6}+539\right)=3804 .
$$