The internet has it that this puzzle was presented to Ramanujan, who solved it almost immediately, because of course he did. He was Ramanujan. It’s supposed to be (and may be) a Dudeney puzzle, but it’s not obviously in the one book of those I have. Here’s the puzzle:

He said the house of his friend was in a long street, numbered on this side one, two, three, and so on, and that all the numbers on one side of him added up exactly the same as all the numbers on the other side of him. Funny thing that! He said he knew there was more than fifty houses on that side of the street, but not so many as five hundred.

I didn’t solve it immediately, because of course I didn’t. I’m not Ramanujan. I did solve it, though – and I suggest you do too, before you look below the line for spoilers.


My solution

My solution is… correct but unsatisfactory. I feel like there must be a nicer way to show it. Let’s work through my thought process.

  • Let’s put the friend in house number $m$ out of the $n$ houses on the street.
  • The sum of the numbers on the low side would be $1 + 2 + \dots + (m-1)$, which is $\frac{m(m-1)}{2}$.
  • The sum of the numbers on the high side is $(m+1) + (m+2) + \dots + n$, which is $\frac{(m+n+1)(n-m)}{2}$.
  • Those two sums are equal, and I’ll double everything to make $m(m-1) = (m+n+1)(n-m)$.
  • At this point, one rolls one’s eyes and expands the brackets to get $m^2 -m = n^+n - m^2 - m$, possibly spotting a difference of two squares on the right.
  • That actually shakes out nicely when you rearrange it, giving $m^2 = \frac{n(n+1)}{2}$ – which means $m^2$ needs to be a triangular number that’s also a square.
  • I know two of those! 36 is $6^2$, and 1225 is $35^2$.
  • Let’s check them!
    • If $m$ is 6, $n$ is 8: the low side is $1+2+3+4+5=15$ and the high side is $7+8=15$, which works!
    • If $m$ is 35, then $n$ is 49 – the low side is 595 and the high side is also 595.
    • Boom! But that doesn’t solve the problem – we need a solution where $n$ is bigger than 50.

How are we going to find one of those?

I’m looking out for the Ninja here. I fear they’ve gone into retirement, but not as much as I fear the Ninja.

We’re going to do some rearrangement.

  • $\frac{n^2 + n}{2} = m^2$ – I’ll multiply it all by 8.
  • $4n^2 + 4n = 8m^2$ – now use difference of two squares on the left.
  • $(2n+1)^2 - 1 = 8m^2$, or…
  • $a^2 - 8m^2 = 1$. I was about to specify that $a$ is odd, but it would have to be. What we’ve got here is a Pell’s equation.

And we know how to solve a Pell’s equation: it needs a continued fraction – in this case, of $\sqrt{8}$. The convergents of this are of the form $\frac{p}{q}$, such that $p^2 \pm 1 = 8q^2$, which is exactly what we need – and in particular, we want the ones where $p$ is slightly larger than $\sqrt{8}$.

The convergents are:

  • $\frac{2}{1}$ – low
  • $\frac{3}{1}$ – high, and $m=1$ is technically a solution.
  • $\frac{14}{5}$ – low
  • $\frac{17}{6}$ – high, recovering the $m=6$ solution.
  • $\frac{82}{29}$ – low
  • $\frac{99}{35}$ – high, recovering the $m=35$ solution.
  • $\frac{478}{169}$ – low
  • $\frac{577}{204}$ – high, and the number we want is 204.

We can also recover $n$ here – the top of the fraction is $(2n+1)$, so we just need to subtract one and halve it. For $m=6$, that gives 8 as before; for $m=35$, we get 49. Hooray!

So our friend lives at house 204 out of the 288 on the street.


Did you solve it a different way? Let me know about it!