4. For any positive integer $n$, if $f(n)=\left\{\begin{array}{l}\log _{8} n \text {, if } \log _{8} n \text { is a rational number; } \\ 0, \text { if } \log _{8} n \text { is not a rational number. }\end{array} \sum_{n=1}^{19 n 7} f(n)=\right.$
A. $\log _{8} 2047$
B. 6
C. $\frac{55}{3}$
D. $\frac{58}{3}$
4. C Since $8=2^{3}$, it is clear that $\log _{8} n$ is a rational number only when $n$ is a power of 2. Noting that $2^{0}<1997<2^{11}=2048$, we have $\quad \sum_{n=1}^{1997} f(n)=\sum_{k=0}^{1024} \log _{8} 2^{k}=\sum_{k=0}^{10} \frac{k}{3}=\frac{55}{3}$. Therefore, the answer is C.