Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

One of my computer science teachers came up with this neat little problem that he and I have both brute-forced and done some analytical work, but we haven't gotten far.

There exist chains of squares such that each square is the previous one but with a digit slapped on the end. For example...

$1\rightarrow 16 \rightarrow 169$
$1^2\rightarrow 4^2 \rightarrow 13^2$

$4 \rightarrow 49$
$2^2 \rightarrow 7^2$

$25 \rightarrow 256$
$5^2 \rightarrow 16^2$

There are an infinite* number of 2-square chains, but beyond the first one, we haven't found any 3-square chains and I have brute-forced it up to 20k (if I recall correctly) to look for more 3-square chains.

I have done some algebraic stuff, but I haven't come up with anything incredibly useful, unfortunately. Here's some of my work...

$n^2 = 10m^2 + k$
$n = m\sqrt{10} + \epsilon$
$n^2 = 10m^2 + 2\epsilon m\sqrt{10} + \epsilon^2$
$k = 2\epsilon m\sqrt{10} + \epsilon^2$
$0 = \epsilon^2 + 2\epsilon m\sqrt{10} + k$
Application of quadratic formula, simplifying, and noting that only the more positive answer is useful...
$\epsilon = -m\sqrt{10}+\sqrt{10m^2-k}$
While neat, this equation hasn't been of much use to me thus far... :P

*The continued fraction for $\sqrt{10}$ gives 2-square chains composed of the squares of the numerator and denominator.

So yeah...anyone have a way to construct 3-square chains? Even a proof that more than two exist would be very helpful.

share|cite|improve this question
See and, although there doesn't seem to be a huge amount to work with there. – Michael Lugo May 6 '11 at 3:29
Interesting: With respect to 2-square chains: I've been playing around a bit: $4^2 \rightarrow13^2$, $6^2 \rightarrow 19^2$, ...and more. What I've noticed in every pair I've encountered so far: exactly one of the two is prime. Hmmm... – amWhy May 6 '11 at 4:14
Oooo...interesting! Something new to investigate! :P – El'endia Starman May 6 '11 at 4:23
Running my brute-force program again, there are two counter-examples right after the ones you put. 12^2 -> 38^2 and 18^2 -> 57^2. – El'endia Starman May 6 '11 at 4:43
Thanks for getting back...oh, well...Nice question, though! – amWhy May 6 '11 at 4:51
up vote 7 down vote accepted

I believe your search is sufficient to prove there are no others. If you let $m$ be the square root of the first in the chain and $n$ be the square root of the third, you have $100m^2+a=n^2$ with $9 \lt a \lt 100$. This becomes $(n-10m)(n+10m)=a$, and $n \gt 10m$, so once $10m \gt 50$ there are no more solutions. Another way to see it is that the smallest $n^2$ can be is $(10m+1)^2=100m^2+2m+1$ and with $m \gt 50$ this will not start with $m$ because of the carry.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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