# Continued Fraction Counting Problem

The house of my friend is in a long street, numbered on this side one, two, three, and so on. All the numbers on one side of him added up exactly the same as all the numbers on the other side of him. There is more than fifty houses on that side of the street, but not so many as five hundred. If we find the number of the house where my friend lives, the problem had one solution — house no. 204 in a street of 288 houses, i.e. 1+2+ ... 203 = 205 + 206+ . . . 288. But without the 50-to-500 house constraint, there are other solutions. For example, on an eight-house street, no. 6 would be the answer: 1 + 2 + 3 + 4 + 5 = 7 + 8. Ramanujan is reported to have discovered a continued fraction comprising of a single expression with all such correct answers. What is the continued fraction, and how can it be found?

• I think it may be the continued fraction for $\sqrt{8}$ or something related. For sure it is the Pellian $x^2-8y^2=1$. – André Nicolas Aug 3 '15 at 3:24

If it is house number $x$ in a street of $y$ houses, we have $$\frac{x(x-1)}{2}+x+\frac{x(x-1)}{2}=\frac{y(y+1)}{2}$$ which simplifes to $$(2y+1)^2-8x^2=1\ .$$ This can be solved by computing the continued fraction $$\sqrt8=2+\frac{1}{1+{}}\frac{1}{4+}\frac{1}{1+{}}\frac{1}{4+\cdots}\ .$$ The table of convergents is $$\matrix{&&2&1&4&1&4&1&4&1&4&\cdots\cr 0&1&2&\color{red}{3}&14&\color{red}{17}&82&\color{red}{99}&478&\color{red}{577}&2786&\cdots\cr 1&0&1&\color{red}{1}&5&\color{red}{6}&29&\color{red}{35}&169&\color{red}{204}&985&\cdots\cr}$$ The pairs beneath the second-last entry in each period (that is, in this case, beneath the $1$s) are marked in red. They give the integer values of $2y+1$ and $x$ satisfying the equation. For example we have firstly $y=1$, $x=1$ (the trivial solution - house numbers on both sides of $1$ add up to $0$). Then $y=8$, $x=6$ as you observed. The fourth solution is Ramanujan's.
Also, if we take the house numbers $$x_0 = 0,$$ $$x_1 = 1,$$ $$x_2 = 6,$$ $$x_3 = 35,$$ $$x_4 = 204,$$ $$x_5 = 1189,$$ we have a simple recurrence $$\color{magenta}{ x_{n+2} = 6 x_{n+1} - x_n }$$ which follows by Cayley-Hamilton from the generator of the oriented automorphism group of $u^2 - 8 v^2.$ If $y_n$ is the number of houses on the street, so $y_n \in \{1,8,49,288,1681, \ldots \}$ then $$\color{magenta}{ y_{n+2} = 6 y_{n+1} - y_n + 2 }$$
The part about the automorphism group comes down to this single identity involving a linear map, $$(3u+8v)^2 - 8(u+3v)^2 = u^2 - 8 v^2$$