We live in a community of houses sequentially numbered from 1 to 100. We all love square dancing but only two immediate neighbors are joy to watch. If you concatenate their house numbers, it forms a true square.

Who are they?

  • $\begingroup$ Very nice puzzle! I'll admit that I found this by checking a lot of possibilities (by hand, not programming anything), but there's a very neat mathematical solution which yields the solution almost without any calculation at all. $\endgroup$ – Rand al'Thor May 9 at 18:58
  • 1
    $\begingroup$ Thx..during my long walks I come up with these..I love to do mental math..I can square most of the numbers upto 1000 mentally.. $\endgroup$ – Uvc May 9 at 19:05

The answer is

$8281$, the concatenation of 82 and 81, which is $91^2$.


We're looking for a perfect square of the form $xyxz$ where $z=y\pm1$. But this equals $101(10x+y)\pm1$, which is congruent to $\pm1$ modulo $101$. So its square root must be less than $100$ but congruent to a square root of $\pm1$ modulo 101.

One of the two cases can be eliminated immediately:

The square roots of $+1$ modulo $101$ are $\pm1$, which are not possibilities. (Note that $101$ is prime, so there are exactly two square roots.)

So we check the other one.

What are the square roots of $-1$ modulo $101$? Clearly $10^2\equiv-1$, but that doesn't give us the solution we need. The other square root is $-10\equiv91$, and that does give us the solution.


  • $\begingroup$ Very neat mathematical proof for general case $\endgroup$ – Uvc May 10 at 2:15

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.