TITLE: Show that this sequence contains infinitely many composite numbers.
QUESTION [8 upvotes]: Let $a_1$ be any number.  Create a sequence $a_1, a_2, a_3$, where $a_n$ is formed by appending a digit from 0 to 8 to the end of $a_{n-1}$.  Show that this sequence contains infinitely many composite numbers.  What happens if you allow for 9?  Can you still guarantee that infinitely many composite numbers must occur?

REPLY [4 votes]: The prime number theorem tells us that $$\pi(n) \sim \frac{n}{\log n}.$$ Granted that this is rather inaccurate for small $n$. But as $n$ gets larger and larger, it becomes more accurate.
So, for example, $$\pi(10^{20}) \sim \frac{10^{20}}{\log 10^{20}} \sim 2171472409516259138$$ and $$\pi(10^{20} + 10) \sim \frac{10^{20} + 10}{\log (10^{20} + 10)} \sim 2171472409516259138.$$ This suggests there are no primes between $10^{20}$ and $10^{20} + 10$. Indeed the next prime is $10^{20} + 39$.
This is relevant to your question because $10a_n < a_{n + 1} < 10a_n + 9$. As $a_n$ gets longer and longer, appending a digit to make a prime becomes more and more difficult. Sure, you'll occasionally run into primes. But for the most part, it's gonna be composite numbers no matter which digit you choose to append. Allowing the digit $9$ might make no difference at all.
To continue the $10^{19}$ example, let's say you append $1$. Then $10^{20} + 1$ is divisible by $73$ and $137$, and a couple other primes I don't feel like typing out. And the next prime after $10^{21} + 10$ is $10^{21} + 117$. You get the idea.