A pile of coins is on the table.
Two players alternate picking coins from the table, where must be a square number. For example, if there are 10 coins on the table, you could take 1, 4 or 9 coins.
The player to take the last coin (or a group containing the last coin) wins!
Martha realizes that if it's her turn, and there are 22 coins in the pile, she can't guarantee a win.
What is the next number greater than 22 for which if it is your turn you will lose assuming both players play optimally?
If you think there are no such numbers, i.e. every number greater than 22 will guarantee you a win, then please provide 0 as the answer.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Let 1 represent a win and 0 represent a loss.
Then in general, whether you win, given n coins, and its your turn to move, is calculated by the following recursion relation:
The second equation is because if you can pick a square number i such that W ( n − i ) = 0 , you will, and will leave the other player with a losing number of coins to play from.
This gives
Therefore 3 4 is the first number greater than 2 2 for which you will lose the game if its your turn and that many coins are in the pile.