# Number of Digits in Power of 2

## Theorem

Let $n$ be a positive integer.

Expressed in conventional decimal notation, the number of digits in the $n$th power of $2$:

$2^n$

is equal to:

$\ceiling {n \log_{10} 2}$

where $\ceiling x$ denotes the ceiling of $x$.

## Proof

Let $2^n$ have $m$ digits when expressed in decimal notation.

By the Basis Representation Theorem and its implications, a positive integer $x$ has $m$ digits if and only if:

$10^{m - 1} \le x < 10^m$

Thus:

 $\displaystyle 10^{m - 1}$ $\le$ $\, \displaystyle 2^n \,$ $\, \displaystyle <\,$ $\displaystyle 10^m$ $\displaystyle \leadsto \ \$ $\displaystyle m - 1$ $\le$ $\, \displaystyle \log_{10} \paren {2^n} \,$ $\, \displaystyle <\,$ $\displaystyle m$ $\displaystyle \leadsto \ \$ $\displaystyle m - 1$ $\le$ $\, \displaystyle n \log_{10} 2 \,$ $\, \displaystyle <\,$ $\displaystyle m$

Because a power of $2$ cannot equal a power of $10$, it will always be the case that:

$m - 1 < n \log_{10} 2 < m$

and so:

$m - 1 < n \log_{10} 2 \le m$
$m = \ceiling {n \log_{10} 2}$

$\blacksquare$

## Examples

### Mersenne Number $M_{127}$

When expressed in conventional decimal notation, the number of digits in the Mersenne number $M_{127}$ is $39$.