I am currently attempting to solve Project Euler problem 162, and have decided to go around it by determining the ratio of numbers in certain bases which have a certain digit $x$ in them.
For base 10 numbers, for example, 10% of the numbers from $1$ - $10$ have the digit 9 in them (namely 9 itself). For the numbers $1$ - $10^2$, 19% of them have the digit 9 in them (9, 19, 29 ... 90, 91, 92 etc). For $1$ - $10^3$, this is 27.1%.
Putting these percentages into a sequence yields: $$10, 19, 27.1, 34.39, 40.951 \ldots$$
Where the first differences ($9, 8.1, 7.29, 6.561$) follow a geometric progression in the form $a_n=9\cdot0.9^{n-1}$.
While I have been able to determine a general formula for these differences, I'm unsure how to actually use this in order to determine the general formula for the sequence that they stem from. How would I go about doing so?
Let the initial term be $a_0=10$. Then, we can express the $n^{\text {th}} $ term as: $$a_n = a_{n-1}+9\times (0.9)^{n-1} $$ You can easily check it's validity.
Using an iterative method and the sum of a geometric progression, we get: $$\begin {align} a_n = a_{n-1}+9\times (0.9)^{n-1}\\ a_n = a_{n-2} + 9\times (0.9)^{n-2}+9\times (0.9)^{n-1} \\ \ldots \\ a_n = a_0 + 9\times (0.9)^0 + 9\times (0.9)^1 + \ldots + 9\times (0.9)^{n-2} + 9\times (0.9)^{n-1}\\ a_n = 10 + 9\frac {(1)(1-(0.9)^n)}{1-0.9}\\ a_n = 10 + 90\left [1-(0.9)^n \right] \end {align} $$