I saw a problem on this forum concerning the number
$$T = 1 + \frac{2 +\frac{3+ \frac {4+...}{5+...}}{4+\frac{5+...}{6+...}} }{3 + \frac{4+\frac{5+...}{6+...}}{5+\frac{6+...}{7+...}}}$$
whose rule is "simple": you add $+1$ as you go up and add $+2$ as you go down, indeed this number can be thought as one of the values of $f(0)$ when $f(x) = x+1 +\frac{f(x+1)}{f(x+2)}$. So I tried to put these numbers on a sequence $a_n$ by dividing this fraction on levels established by the division line.
For example, on level one we would have the element $a_1=1$. Because we're done with this level we move to the top of the next level.
Level $2$ is the level which starts with $2$ and only has the elements $a_2=2$ and $a_3=3$. We move to level $3$.
Level $3$ has four elements, it starts at $a_4=3$ then we go down: $a_5=4,a_6=4,a_7=5$ and on level $4$ we have $a_8=4, a_9=5,a_{10} = 5, a_{11} = 6, a_{12}=5, a_{13}=6, a_{14} = 6, a_{15} = 7$.
What I want is a general formula for the terms of sequence $a_n$:
$$(a_n) = (1,2,3,3,4,4,5,4,5,5,6,5,6,6,7,5,6...)$$
It is clear that the $i$-th level has $2^{i-1}$ elements, so I thought about defining $b_{i,j}$ as the $j$-th term of the $i$-th level ($1 \le j \le 2^{i-1}$). As $i =\lfloor \log_2 n \rfloor +1$, we have $a_n = b_{\lfloor \log_2 n \rfloor +1, n -\lfloor \log_2 n \rfloor}$, my problem now is finding the pattern in the levels.
It is easy to see that $b_{i,1} = i$ for all $i \geq 1$ and that $b_{i,2^{i-1}} = 2i-1$. I used the following recurrence relations to try to establish this formula:
$$\begin{cases}b_{i+1,2j} = b_{i,j} + 2 \\ b_{i+1, 2j-1} = b_{i,j} + 1\\ b_{i,1}=i\end{cases}$$
which should translate the property of "up = $+1$", "down = $+2$" and that each level starts with $i$ but I'm not sure why this isn't enough. We can see it fails on the level $4$ when we repeat the fraction $\frac56$. But how can I conclude that in the middle this happens? The expression $b_{i,j} = i + \lfloor \frac j2 \rfloor$ seems to describe the level until half of it, how can I fix this and get a formula? Is it enough to split the level in two parts?
EDIT: I saw this is really a graph and it seems that the repetition of terms follows the Pascal triangle, which I mean by this is that on the level $5$ the repetition goes like $1,4,6,4,1$: $1$ five, $4$ sixes, $6$ sevens, $4$ eights and $1$ nine. This is easy to prove with induction I believe.
EDIT²: here is the original question Simplifying a complicated continued fraction expression.
EDIT³: I managed to prove that $b_{i,4k-1} = b_{i,4k-2}$ for all $k \geq 1$ and any $i \geq 3$, those are indeed the only consecutive positions on the level on which equality occurs.
EDIT4: The problem is now equivalent to find a formula for the elements of the following sequence of vectors:
$$b_3 = [-1], b_4 = [-1,-2,-1] , b_5 = [-1,-2,-1,-3,-1,-2,-1] ,..., b_n$$
with $b_{n+1} = b_n + [2-n] + b_n$ where the plus means concatenation of lists/vectors and $[2-n]$ is a vector with the element $2-n$. This last task is holding me, a formula for $b_{n,k}$ is a formula for $a_n$