# Is it the case that there is some string, S, such that every string ending in S ends a perfect square? If so, is the same true for every power?

I am not a mathematician, but I gather from this paper that any string of digits ending in '1', '3', '7', or '9', no matter what it is, is the ending sequence of the decimal representation of infinitely many cubes. This other paper extends this result to other exponents that are relatively prime to 10. Each paper holds out the case of squares for further study.

My question is: does this hold for squares? Is it the case that there is some string of digits, S, such that every string ending in S is itself the ending of infinitely many squares? If so, does this result hold for every other exponent too, so that fourth powers, fifth powers etc. will also have some string, S, such that every string ending in S is itself the ending of infinitely many fourth powers (or fifth powers, etc. as the case may be)?

(I am told that this German paper should answer my question, but, alas, I don't read German.)

I am not a mathematician, so I am afraid that any answers will have to be spelt out very clearly for me.

Thanks very much for any help that anyone can give -- much appreciated.

The answer to your question is yes, there do exist strings $$S$$ for which, given any string $$T$$ that finishes with $$S$$, there exist infinitely many square numbers whose final digits are the string $$T$$.
We know from the Chinese remainder theorem that the group of units $$(\mathbb{Z}/10^k \mathbb{Z})^{\times} \cong (\mathbb{Z}/2^k \mathbb{Z})^{\times} \times (\mathbb{Z}/5^k \mathbb{Z})^{\times}$$. For all $$k \geqslant 1$$ we have $$(\mathbb{Z}/5^k \mathbb{Z})^{\times} \cong C_{\varphi(5^k)} \cong C_{4 \cdot 5^{k-1}}$$ by the theory of primitive roots. Similarly, for all $$k \geqslant 3$$, we have $$(\mathbb{Z}/2^k \mathbb{Z})^{\times} \cong C_2 \times C_{2^{k-2}}$$. Putting this all together we have $$(\mathbb{Z}/10^k \mathbb{Z})^{\times} \cong C_2 \times C_{2^{k-2}} \times C_{4 \cdot 5^{k-1}}$$ and so there are $$\frac{1}{8}\vert (\mathbb{Z}/10^k \mathbb{Z})^{\times}\vert = 2^{k-2} \cdot 5^{k-1}$$ squares modulo $$10^{k}$$ that are comprime to $$10$$. This increases by a factor $$10$$ when $$k$$ goes to $$k+1$$, so it follows that all possible extensions of the squares in $$(\mathbb{Z}/10^k \mathbb{Z})^{\times}$$ must be squares in $$(\mathbb{Z}/10^{k+1} \mathbb{Z})^{\times}$$. Taking $$S$$ to be the set of quadratic residues modulo $$10^3$$ that are comprime to $$10$$ (chosen to lie between $$1$$ and $$999$$), we see that all strings in $$S$$ are suitable.