# Avoiding matching first digit of $a^n$ with $b^n$

For any given pairs of positive integers $a$ and $b$, is it possible that the first digit of $a^n$ never matches the first digit of $b^n$ for any positive integer $n$?

(If $a=2$ and $b=5$ the only possible matching first digit is "3".)

Edit: I meant to say $a=2$ in the parenthetical comment above. I had previously written $a=3$, which does not work as several comments indicate.

-
@Fixee: I have edited your post so that the first sentence makes mathematical sense. If this is not what you meant, please let me know. –  TonyK May 31 '11 at 20:16
@Fixee: How do you get the result in your last sentence? It surprises me. –  TonyK May 31 '11 at 20:19
And in fact it surprises my laptop too, which insists that $3^9=19683$ and $5^9=1953125$. –  TonyK May 31 '11 at 20:29
Not a proof, but you are just looking for $\left(\frac{b}{a}\right)^n\approx 10^m$ You can get this very close taking $m\approx k\log_{10}\frac{b}{a}$ for some $m,k$. I would be very surprised if you always miss. –  Ross Millikan May 31 '11 at 20:38
In view of user6312's comment to Alon Amit's answer below, $a=3$ may just be a typo for $a=2$. –  TonyK May 31 '11 at 21:30

## 2 Answers

I was also thinking along the lines of Ross Millikan's comment. The first digit (in base 10) of $a^n$ is determined by the fractional part of $\log_{10}(a)$; specifically, the interval $[0,1]$ is partitioned into buckets $[0,\log_{10}(2)), [\log_{10}(2), \log_{10}(3))$, etc. The first digit of $a^n$ and $b^n$ would be the same of $n\log(a)$ and $n\log(b)$ fall into the same bucket, which would follow from the fractional part of $m\log(a/b)$ being smaller than the smallest bucket for some $m$, which means either $m$ or $m+1$ would do the trick.

Now $\log_{10}(a/b)$ is irrational except if $a/b$ is a power of 10, but in the latter case the result is obvious. For an irrational quantity, the fractional parts are dense in the unit interval and the result follows from the considerations above.

-
Apart from $a$ or $b$ being powers of $10$, the only unusual case is when $ab$ is a power of $10$. Then the only common first digit is $3$. –  André Nicolas May 31 '11 at 21:03
I think that if $a$ is not a rational power of $b$ then $\{\log a\},\{\log b\}$ are asymptotically independent. –  Yuval Filmus May 31 '11 at 21:34
The difficult thing is to prove that even though $\left(\frac{a}{b}\right)^n$ is very close to a power of $10, a^n$ and $b^n$ don't fall just on opposite sides of a bucket boundary. We "know" it is true, but I don't see an easy proof. –  Ross Millikan May 31 '11 at 22:32
If there is no relation $a^i b^j 10^k = 1$ for integers $i$, $j$, $k$, then $\log_{10}(a), \log_{10}(b), 1$ are linearly independent over the rationals, and then the sequence of pairs $(\{n \log a\}, \{n \log b\})$ is uniformly distributed in $[0,1]^2$. See e.g. maths.manchester.ac.uk/~cwalkden/ergodic-theory/lecture07.pdf. –  Robert Israel Jun 1 '11 at 3:53

I'm not answering the question, but justifying the claim in the last sentence of the question: when $a=2$ and $b=5$ the only shared leading digit of $a^n$ and $b^n$ is 3.

Suppose $2^n$ and $5^n$ share leading digit $d$ and have $r+1$ and $s+1$ digits, resp. For $n>3$ we have $d10^r < 2^n < (d+1)10^r$ and $d10^s < 5^n < (d+1)10^s$. Therefore $d^2 10^{r+s} < 10^n < (d+1)^2 10^{r+s}$ so $d^2 < 10^{n-r-s} < (d+1)^2$. Since $d$ is a digit, $d \geq 1$ and $(d+1) \leq 10$; these restrictions force $n-r-s = 1$, so $d^2 < 10 < (d+1)^2$ meaning only $d=3$ works. And since $2^5 = 32$ and $5^5 = 3125$ it does in fact occur as a leading digit.

-