Let the given sequence be,
$$1,6,9,11,16,19,61,66,69,91,96,99,111,116...$$
If $A_n$ represents the $n^{th}$ term of this sequence then calculate:
- $A_{100}$
- $A_k=16619,$ find $k$?
My Attempt :
I was able to hardwire the solution, but I don't find it decent enough and I think that there must be a more mathematical solution to this.
I saw that the sequence was of type,
$$1,6,9$$ $$(A_1)1,(A_1)6,(A_1)9$$ $$(A_2)1,(A_2)6,(A_2)9$$ $$(A_3)1...$$
To calculate $A_{100}$, I was able to conclude that
$$A_{100}=(A_{33})1$$
Further, $A_{33}=(A_{10})9$
$A_{10}=(A_3)1=91 \implies A_{33}=(A_{10})9=919 $
$$A_{100}=9191$$
For the second part, I started breaking up the $n^{th}$ term,
$$A_k=16619=(A_m)9$$
$$A_m=1661=(A_n)1$$
$$A_n=166=(A_p)6$$
$$A_p=16 \implies p=5 $$
$$A_n=(A_5)6 \implies n=5*3+2=17$$
$$A_m=(A_{17})1 \implies n=17*3+1=52$$
$$A_k=(A_{52})9 \implies n=52*3+3=159$$
$$k=159$$
I know that both the solutions are correct. But how do I approach it more professionally?
If you rewrite the numbers with the substitution $169\leftrightarrow012$, the sequence
$$0,1,2,00,01,02,10,11,12,20,21,22,000,001...$$
is enumerating all the base-$3$ numbers with $1,2,3,\cdots$ digits.
The starting indexes of the subsequences of $d$ digits are
$$1,1+3,1+3+3^2,1+3+3^2+3^3,\cdots=1+\frac32(3^{d-1}-1).$$
Then $a_{100_{10}}$ is a number of $4$ digits (they start at $A_{40_{10}}$), namely $60_{10}$, written $2020_3$, i.e. $9191$.
And $16619$ corresponds to $01102_3=38_{10}$, counting from $121_{10}$, i.e. $k=159_{10}$.
The general formula is a little difficult. For the $k^{th}$ term, consider
$$d=\left\lfloor\log_3\left(\frac23(k-1)+1\right)\right\rfloor.$$
Then
$$a_k=k-1-\frac32(3^{d-1}-1),$$
which must be written in base $3$ with $d$ digits, and the digits renamed $012\leftrightarrow169$.
Conversely, to get $k$, rename to a base-$3$ number and take its value, to which you add the offset corresponding to the number of digits.