# How to prove that all primes $p$ will have a power $p^k$ with a $2$ in its decimal representation?

How to prove that all primes $p$ will have a power $p^k$ with a $2$ in its decimal representation?

This is a lemma I need to prove a problem I'm working on. My attempt: Suppose for the sake of contradiction that there exists a prime, $p$ such that none of its powers has a $2$ in its decimal representation. Then $p^k \not \in [2 \cdot 10^q, \; 3 \cdot 10^q) \; \; \forall \; p,q \in \mathbb{N}$. This should be a contradiction because prime powers are placed arbitrarily in the decimal system. Any help??? Thanks in advance.

• try proving this for all numbers and not just primes. – Guy Mar 22 '14 at 10:07
• except $10^k$ I think it holds. – Guy Mar 22 '14 at 10:08
• We might be able to "work backwards" from a power $p^{2k}$ whose leading digit is 2, i.e. $2\cdot 10^m \le p^{2k} \lt 3\cdot 10^m$, to get an expanded target for $p^k$'s leading digits. – hardmath Mar 22 '14 at 10:24

Let $a$ be an integer that is not a power of $10$. We show that for any digit $d\ne 0$, there is a $k$ such that $a^k$ has leading digit $d$. We use more machinery than necessary, to make generalization to bases other than $10$ natural.
It is enough to show that there is an exponent $e$ and an integer power $10^q$ of $10$ such that $$10^q \lt a^e \lt 10^q(1+\frac{1}{10}).$$ For then the first digit of $a^e$ is $1$, and the first digit of $(a^e)^{i+1}$ is either the same as the first digit of $(a^e)^i$, or is one more, except possibly in the case the first digit of $(a^e)^i$ is $9$. Thus all $9$ non-zero digits occur as first digits among the powers of $a^e$.
Since $a$ is not a power of $10$, it follows that $\log_{10} a$ is irrational. We want to show that there is an integer $e$ such that the fractional part of $e\log_{10} a$ is between $0$ and $\log_{10}\left(1+\frac{1}{10}\right)$. That there is such an $e$ is straightforward. Because $\log_{10} a$ is irrational, the fractional parts of $n\log_{10} a$, as $n$ ranges over the positive integers, are dense in $[0,1]$.