A few weeks ago, Scott Matlick reached out to me with observations about the relative likelihood that a positive integer with a given number of digits would be a perfect square. And that got us both wondering. For some perfect squares, when you remove the last digit, you get another perfect square. For example, when you remove the last digit from 256 ($16^2$), you get 25 ($5^2$).
The first few squares for which this happens are 16, 49, 169, 256 and 361. What are the next three squares for which you can remove the last digit and get a different perfect square? How many more can you find? (Bonus points for not looking this up online or writing code to solve it for you! There are interesting ways to do this by hand, I swear.)
Extra credit: Did you look up the sequence and spoil the puzzle for yourself? Good news, there’s more! In the list above, 169 ($13^2$) is a little different from the other numbers. Not only when you remove the last digit do you get a perfect square, 16 ($4^2$), but when you remove the last two digits, you again get a perfect square: 1 ($1^2$). Can you find another square with both of these properties?
The given description asks for:
$$l^2 = A$$
$$m^2 = 10A + B$$
where $A$, $B$, $l$, and $m$ are integers, $0 \le B \le 9$
Let $m = 3l + x$. Substituting yields:
$$(3l+x)^2 = 10l^2 + B$$
$$9l^2 + 6lx + x^2 = 9l^2 +(l^2 + B)$$
$$l^2 - 6lx + (B - x^2) = 0$$.
$l^2 - 6l + (B - 1) = 0$
$B = 6$.
If $l = 1$, $16 \rightarrow 1$
If $l = 5$, $256 \rightarrow 25$
$B = 9$.
If $l = 2$, $49 \rightarrow 4$
If $l = 4$, $169 \rightarrow 16$
$B = 10$, which contradicts the given.
$B = 1$.
$l = 6$, $361 \rightarrow 36$
$l^2 - 12l + (B - 4) = 0$
$(l-12)(l) = 0$
$B = 4$.
$l = 12$, $1,444 \rightarrow 144$
$l^2 - 18l + (B - 9) = 0$
$(l-18)(l) = 0$
$B = 9$.
$l = 18$, $3,249\rightarrow 324$
$x=4,5,6$ did not have solutions. Finding sums $=-6lx$ and products $= B-x^2$ became difficult as $B$ is constrained to a single digit integer.
The next $5$ solutions followed the pattern that the quadratic $l^2 - 6lx + (B - x^2)$ factors to $(l+k)(l - 6lx - k)$ for $x = 6k+1$, $1 \le k \le 5$.
$l^2 - 42l + (B - 49) = 0$
$(l+1)(l-43) = 0$
$B = 6$.
$l = 43$, $18,496 \rightarrow 1,849$
$l^2 - 78l + (B - 169) = 0$
$(l+2)(l-80) = 0$
$B = 9$.
$l = 80$, $64,009 \rightarrow 6,400$
$l^2 - 150l + (B - 625) = 0$
$(l+4)(l-154) = 0$
$B = 9$.
$l = 154$, $237,169 \rightarrow 23,716$
$l^2 - 186l + (B - 961) = 0$
$(l+5)(l-191) = 0$
$B = 6$.
$l = 191$, $364,816 \rightarrow 36,481$
$l^2 - 222l + (B - 1369) = 0$
$(l+6)(l-228) = 0$
$B = 9$.
$l = 228$, $519,841 \rightarrow 51,984$
$1,444$, $3,249$, and $18,496$ are the next three perfect squares.
The problem is now
$$l^2 = A$$
$$m^2 = 10A + B$$
$$n^2 = 100A + 10B + C$$
where $A$, $B$, $C$, $l$, $m$, and $n$ are integers, $0 \le B,C \le 9$
Substituting $n = 9l + 3x + y$ on the left, and again, $m = 3l + x$ on the right:
$$(9l + 3x + y)^2 = 10(3l+x)^2 + C$$
$$81l^2 + 54lx + 18ly + 9x^2 + y^2 + 6xy = 90l^2 + 60lx + 10x^2 + C$$
$$0 = 9l^2 + 6lx-18ly + x^2-y^2-6xy + C$$
$$ = 9l^2 + 6l(x-3y) + (x^2-y^2-6xy + C)$$
$l = 1$, $x = 1$, and $y = 1$ yields $169 \rightarrow 16 \rightarrow 1$. I have not yet found an additional solution.