4. $[x]$ represents the greatest integer not exceeding the real number $x$. If
$$
\left[\log _{3} 6\right]+\left[\log _{3} 7\right]+\cdots+\left[\log _{3} n\right]=2009 \text {, }
$$
determine the value of the positive integer $n$.
4. For $3^{k} \leqslant i \leqslant 3^{k+1}-1$, we have $\left[\log _{3} i\right]=k$. Therefore, $\sum_{i=3^{k}}^{3 k+1}\left[\log _{3} i\right]=2 \times 3^{k} k$.
Also, $3+\sum_{k=2}^{4} 2 \times 3^{k} k<2009<3+\sum_{k=2}^{5} 2 \times 3^{k} k$, hence $3^{5}<n<3^{6}-1$.

From $3+\sum_{k=2}^{4} 2 \times 3^{k} k+5\left(n-3^{5}+1\right)=2009$, solving for $n$ gives $n=474$.