# Find the smallest $n$ such that the digits in $2^n$ have every digit from $1$ to $9$

Find the smallest $n$ such that the digits in $2^n$ have every digit from $1$ to $9$.

Like, the smallest power of $2$ that it has every digits from $1$ to $9$, excluding $0$.

Is there a way to do this without "brute force"?

-
I would be shocked if this could be done any more efficiently than trying successive powers of 2 (beginning with $2^{27}$ which has 9 digits). On the other hand, one can show without brute force that there exists such an $n$ (indeed there is an $n$ such that $2^n$ starts with $123456789$). Also, $2^{29}$ comes really close but has a $0$ instead of a $4$. –  Erick Wong Aug 5 '13 at 3:22
@ErickWong How can one show without brute force that there exists such an $n$? –  Fixed Point Aug 5 '13 at 3:34
@FixedPoint: It boils down to the fact that $\log 2$ (to base $10$) is irrational, and therefore the sequence of fractional parts of $n \log 2$ is dense in $[0, 1]$. See this question for instance. (In more detail, for $2^n$ to start with $123456789$, we need that for some $k$, we have $123456789(10^k) \le 2^n < (123456789+1)10^k$, which means that $\log(123456789) \le n\log 2 - k < \log(123456789+1)$.) –  ShreevatsaR Aug 5 '13 at 4:02
@FixedPoint To prove that it is sufficient to show that $k \mod \log_2 10 \in [\log_2 1.23456789, \log_2 1.2345679)$ for some $k$. This is the case since $\log_2 10$ is irrational. –  Yury Aug 5 '13 at 4:03
I don't think there is too much point in insisting a non-brute force approach in this case. For a random $N$ digit number, a rough upper bound of probability that it doesn't contain all digits is $10 (0.9)^N$. This number starts to drop below 1 at $N = 22$. Since $2^n$ contains $\lfloor n \log_{10}2\rfloor + 1 \sim 0.3 n$ digits. We should expect to find $2^n$ which uses all digit for $n$ not too far away from $22/0.3 \sim 70$. As the other answer demonstrate, $2^{51}$ already contains all digits. –  achille hui Aug 5 '13 at 7:09

$$2^{51} = 2251799813685248$$
For $3$ it is $3^{68}=78128389443693511257285776231761$. Below exponent $68$ it is often difficult to avoid a zero digit. –  Dietrich Burde Aug 5 '13 at 11:39