# Mathematical problem with square numbers in the decimal system

Moderator Note: this is a question from the Federal Mathematics Competition 2013.

Good morning, here's another (pretty difficult) mathematical problem... The task may sound a little strange (I'm from Germany), but I hope you don't mind :)

Anja and Bernd are playing the following game: They alternatingly write down digits on the blackboard. Anja starts. Every additional digit is written down either to the right or to the left of the digits already written on the blackboard. Prove that Anja can prevent the line of digits (including any leading zeros) from representing a square number in the decimal system after any move by Bernd.

Thank you for good answers (at least I hope so)

Markus

-
I suppose you mean Anja can prevent a square nukber from appearing after any step of Bernd, not just after one step. And that the game goes on forever. – Marc van Leeuwen Jan 5 at 10:58
What are your thoughts on this? What have you done, have you tried some examples...? – DonAntonio Jan 5 at 10:59
yes it has to be after any step of Bernd... i translated it wrong :/ – user55214 Jan 5 at 11:47
she could add for example a 5 at the right side... there's no square number from 50 to 59... – user55214 Jan 5 at 11:53
oh no, that doesn't work... 256 is a square number :/ – user55214 Jan 5 at 11:54
show 1 more comment

## 1 Answer

There are no squares ending $2$ or $3$. Thus if Anja adds a $2$ or a $3$ on the right, Bernd would also have to add a digit on the right to form a square. If $n$ has at least $2$ digits, $n^2$ and $(n+1)^2$ differ by more than $20$. Thus, given any number, at most one of adding a $2$ or a $3$ on the right allows Bernd to form a square, since otherwise the two squares would differ by less than $20$. Thus Anja can write a $5$ in her first move, as you pointed out, and from then on she can always choose at least one of $2$ or $3$.

-
But what about for example 5329 (73²)? In this case Anja couldn't prevent Bernd from building a square number – user55214 Jan 5 at 12:17
@user55214: The algorithm that joriki recommends to Anja would tell that if she sees 53 on the blackboard, she should extend it to 533 rather than 532. In other words, she should not always write a two to the end, but rather first check, whether a two allows Bernd to win, and then if it does, write a three instead. – Jyrki Lahtonen Jan 5 at 12:59
And then Bernd will never ever be able to win? – user55214 Jan 5 at 14:01
@user55214: Yes. – joriki Jan 5 at 15:06
If she writes 5, he writes 2 on the left and wins. But starting with 7 works. – Ross Millikan Jan 6 at 22:13
show 1 more comment