# Math game strategy

Two players are playing the following game. They start with number 2013. Then they take turns subtracting from the number any of its non-zero digits. Example: 2013 → 2011 → 2009 → . . . However, 2013 → 2007 is not a legal move, because there is no 6 in 2013. The player who writes down 0 wins. Which player wins if they both play optimally and what is their strategy?

I've never had a grasp for strategy on these math games, and am looking for an answer as well as a way I can find the winning strategy quickly.

• Well, the usual thing is to start establishing "winning numbers". For example, any single digit is a winning number because if you hand me a single digit I can subtract the full value to get $0$. It follows that $10$, say, is a losing number. And $11,12,13,14,15,16,17,18,19$ are all winning numbers because I can hand you $10$, which we have seen is a losing number. $20$ is then a losing number. And so on. – lulu Nov 8 '16 at 2:21
• @lulu That isn't correct because you can only subtract the digits of the numbers, which is one number. – Gerard L. Nov 8 '16 at 2:23
• I don't understand. If you hand me $17$, say, I subtract $7$ and hand you $10$. You then have to subtract $1$ and hand me $9$ I then win by subtracting $9$. Therefore $17$ is a winning number. – lulu Nov 8 '16 at 2:24
• Pretty easy to see that the two digit losing numbers are $10,20,30,40,50,60,70,80,90$. Now you have to look at it to see what happens as you round $100$. – lulu Nov 8 '16 at 2:26
• @lulu ahhh now I understand – Gerard L. Nov 8 '16 at 2:30

The losing numbers are precisely the multiples of $10$ (so $2013$ is a winning number). That is to say, player $1$ always wins (assuming optimal play) unless the starting number is a multiple of $10$.
To see this, consider the following strategy: if you are handed a number which is not a multiple of $10$, subtract the constant term and give your opponent a multiple of $10$. It is clear that your opponent can never win (as subtracting a single digit can never yield $0$).
• Your opponent never can write $0$, because the number that he handed is a multiple of $10$, and before his turn he write a number of residue different of $0$ module $10$ (remember he subtract digits) – Ricardo Largaespada Nov 8 '16 at 2:39