Srinivasa Ramanujan was said to have answered this riddle almost immediately when brought to his attention by Prasanta Chandra Mahalanobis, taken from a December 1914 print of The Strand Magazine:

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.

What House number did his friend live in?

Note: the house of his friend is not included in either sum

Bonus question: How can you find all possible solution(s) for any number of houses?

You can read more about the context of this puzzle here here or you can watch the mathologer video Jaap Scherphuis commented below


The problem proposed by Dudeney in the Strand Magazine can be solved by Pell's equation $x^2 - d y^2 = 1$. Solving Pell's equation uses continued fractions. So it is not weird that Ramanujan answered by a continued fraction. But, it's astounding that he answered as soon as he heard the problem.

What was his continued fraction in the world? As I know, the answer was not recorded. Maybe Mahalanobis forgot it.

Some mathematicians have delved for it. John Butcher proposed $$ 3 - \dfrac{1}{6-\dfrac{1}{6-\dfrac{1}{6-\dots}}} $$ which gives convergents $$ 3,\quad \frac{17}{6},\quad \frac{99}{35},\quad \frac{577}{204},\quad \frac{3363}{1189},\quad \dots. $$

Note that 204 is the answer of the original problem and the numerator 577 is the total number of houses. Also, this gives all solutions as well as (204,577). How fantastic!

Other continued fractions were proposed. For example, Poo-Sung Park (yes, it's me) proposed $$ 5 + \dfrac{1}{1+\dfrac{1}{4+\dfrac{1}{1+\dfrac{1}{4+\dots}}}} $$ which gives convergents $$ 5,\quad \frac{6}{1},\quad \frac{35}{6},\quad \frac{204}{35},\quad \frac{1189}{204},\quad \dots. $$

This yields the general solutions for the house number: 6, 35, 204, 1189, ....


The sum of the lower numbers is n(n-1)/2.
The sum of the entire street is m(m-1)/2.
Adding the friends house (n) half to to both sides gives n(n-1)/2 + n/2 is half of m(m-1)/2
2nn = m(m-1) can only be true if m and m-1 are a square and twice a square.
checking the odd squares gives 17*17=2*12*12+1
So n is 204 is a solution

  • $\begingroup$ The friends house isn’t included in the sum, should I mention that in the puzzle? I hope to avoid confusion. $\endgroup$ – Cotton Headed Ninnymuggins Sep 24 '20 at 19:10
  • $\begingroup$ It was clear to me.. If it was included the side should be mentioned. However I would find 'the house' i.s.o. 'him' clearer. $\endgroup$ – Retudin Sep 24 '20 at 19:14
  • $\begingroup$ I would put that in there but it was a direct quote from the website (which quoted it from the paper) $\endgroup$ – Cotton Headed Ninnymuggins Sep 24 '20 at 19:15
  • $\begingroup$ 144 shouldn’t be a solution either, the sum of #’s between 1 and 143 equals 10296 and the sum of #’s between 145 and any whole number does not equal 10296 $\endgroup$ – Cotton Headed Ninnymuggins Sep 24 '20 at 19:24
  • $\begingroup$ Stupid mistake, should be 12*17 iso12*12 $\endgroup$ – Retudin Sep 24 '20 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.