# Find the immediate square dancing neighbors, they dance together to perfect square

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?

• 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. – Rand al'Thor May 9 at 18:58
• 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.. – Uvc May 9 at 19:05

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

Proof:

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.

QED.

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