4. (1994 AIME Problem) For a real number $x$, $[x]$ denotes the greatest integer not exceeding $x$. Find the positive integer $n$ such that $\left[\log _{2} 1\right]+$ $\left[\log _{2} 2\right]+\left[\log _{2} 3\right]+\cdots+\left[\log _{2} n\right]=1994$.
4. Let $S_{n}=\left[\log _{2} 1\right]+\left[\log _{2} 2\right]+\left[\log _{2} 3\right]+\cdots+\left[\log _{2} n\right]$.

Obviously, for non-negative integer $k$, there are $2^{k}$ positive integers
$$
2^{k}, 2^{k}+1,2^{k}+2, \cdots, 2^{k+1}-1
$$

such that when $x$ equals any of these $2^{k}$ positive integers, $\left[\log _{2} x\right]=k$. Therefore, for any positive integer $r$, we have
$$
S_{2^{r-1}}=0+(1+1)+(2+2+2+2)+\cdots+[\underbrace{(r-1)+(r-1)+\cdots+(r-1)}_{2^{r-1} \uparrow}] \text {. }
$$

The right side of this expression has
$$
\begin{array}{l}
2^{r}-2^{1} \quad \text { terms not less than } 1 ; \\
2^{r}-2^{2} \quad \text { terms not less than } 2 ; \\
2^{r}-2^{3} \quad \text { terms not less than } 3 \text {; } \\
\cdots \\
2^{r}-2^{r-1} \quad \text { terms not less than } r-2 ; \\
2^{r}-2^{r-1} \quad \text { terms not less than } r-1 .
\end{array}
$$

Therefore,
$$
\begin{aligned}
S_{2^{r-1}} & =\left(2^{r}-2^{1}\right)+\left(2^{r}-2^{2}\right)+\cdots+\left(2^{r}-2^{r}{ }^{2}\right)+\left(2^{r}-2^{r}{ }^{1}\right) \\
& =(r-1) \cdot 2^{r}-\left(2^{r}-2\right) \\
& =(r-2) \cdot 2^{r}-2 .
\end{aligned}
$$

When $r=8$, from the above formula we get $S_{255}=15391994$.
It is clear that if $S_{n}=1994$, then $255<n<511$.
Thus we have
$$
1994=S_{n}=S_{255}+(n-255) \cdot 8 \text {, i.e., } 1994=8 n-502 .
$$

Solving for $n$ gives $n=312$.