Prime condition!

You and a friend play a game where you start with a pile of 100 stones.

You alternate turns, and each turn you can take a prime number stones.

The player that takes the last stone (leaving nothing in the pile) wins!

Which player can guarantee a win?


Note : If only one coin remains, the game is considered a draw.

The first player Neither of them The second player

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.

3 solutions

Saul Spatz
Jan 7, 2018

This is very easy if you consider the games with varying numbers of stones to start. Classify the starting positions as wins, draws, or losses according to the outcome from the point of view of the first player, with optimum play by both sides. All primes are wins, since the first player picks up all the stones, and 1 is a draw. Position n n will be a win if and only if n n is prime, or the first player can move to a loss position. Now 4 is a draw, (remove 3 stones) so the first player can secure at least a draw in all even numbers greater than 4 (remove 2 stones and proceed by induction,) and in any odd composite (remove 3 stones). But this shows that there are no losses, so the the only way to win is by picking up all the stones on the first move. Primes are wins, non-primes are draws.

Joseph Newton
Jan 5, 2018

When a player takes a prime number of stones, they must reduce the number of stones in the pile to a composite number. Otherwise, the opponent would be able to take the prime number of remaining stones and win the game.

To force a win, a player must reduce the stones to a number which will yield a prime if any prime number is subtracted from it. This will force the opponent to bring the stones down to a prime number, which can then be taken and the game won by the player forcing the move. Therefore, for the game to be won there must exist some composite number N N such that N p is prime for all prime values of p < N N-p \text{ is prime for all prime values of }p<N N N must be composite, because if N N were prime the opponent could take all the stones and win. The smallest positive composite number is 4. If the number of stones reaches 4, the game is trivial; the only primes left are 2 and 3, and since taking 2 leaves 2 stones remaining which would allow the other player to win, the player must take 3, leaving 1 stone and drawing the game, so 4 is not a possible value of N N . 5 is prime, and so would also not be a valid value of N N .

But, for every N > 5 N>5 , you can always subtract a prime to end up with a composite number. If the number is even, you simply subtract 2 resulting in another even number, which is of course composite. If the number is odd, you simply subtract 3 resulting in, again, an even number. Therefore all composite numbers greater than 5 can be reduced to another composite number by subtracting a prime. This means no value of N N will force the opponent to reduce the number of stones to a prime number, and the game cannot be won if both players play optimally. Therefore, the answer is Neither of them \boxed{\text{Neither of them}}

Ah yes... This is a lot more along my line of reasoning when I first thought up the problem. Thanks for the solution!

Geoff Pilling - 3 years, 5 months ago
Mark Hennings
Jan 5, 2018

We need to analyse this problem in two stages - the prospect of a draw makes things complicated. It is worth noting that the version of the game where someone unable to play loses (so that what is now a draw is not possible) was first analysed by the mathematician Shannon.

Starting first by playing for a win or a draw, we can calculate the Sprague-Grundy function G G for this game. This is defined as follows: G ( 0 ) = G ( 1 ) = 0 G ( n ) = mex { G ( n p ) p n , p prime } n 2 \begin{aligned} G(0) \; = \; G(1) & = \; 0 \\ G(n) & = \; \text{mex}\{G(n-p) \; |\; p \le n \,,\, p \text{ prime}\} \hspace{2cm} n \ge 2 \end{aligned} where the "mex" (minimum excluded) of a set is the smallest non-negative integer not in that set. The first 11 11 values of G G are 0 , 0 , 1 , 1 2 , 2 , 3 , 3 , 4 , 0 , 0 0\,,\,0\,,\,1\,,\,1\,\,2\,,\,2\,,\,3\,,\,3\,,\,4\,,\,0\,,\,0 and the first few values of n n for which G ( n ) = 0 G(n) = 0 are 0 , 1 , 9 , 10 , 25 , 34 , 35 , 49 , 55 , 85 , 91 , 100 0,1,9,10,25,34,35,49,55,85,91,100 .

Note that G ( 100 ) = 0 G(100) = 0 . Thus any play that the first player makes must result in a number in the pile with positive G G -value, and hence the second player can then respond with a play that returns the G G -value to 0 0 . Thus the second player will be able to guarantee that the play eventually results with either 1 1 or 0 0 stones in the pile. In other words, the second player is guaranteed of either winning for getting a draw.

It is important to note that the second player must always play to leave a number of stones in the pile with a G G -value of 0 0 , since otherwise the first player could either win or draw. Thus the second player's optimal strategy is always to play to achieve a G G -value of 0 0 . As we have seen above, she can always do that.

The question is whether the first player can play for a draw, or whether the second player can force a win. Suppose that the first player's first play is to remove 79 79 stones, leaving 21 21 stones in the pile. The second player must aim for a G G -value of 0 0 , and can only do this by removing 11 11 stones from the pile, leaving 10 10 stones. The first player can now remove 2 2 stones, leaving 8 8 in the pile. The only thing the second player can now do (without handing the game over to the second player) is remove 7 7 stones, leaving just 1 1 stones, and therefore obtaining a draw.

Thus the first player cannot win, but can force a draw. Neither \boxed{\text{Neither}} player can force a win.

Nice write-up Mark... I hadn't gotten around to writing one up myself, but this is far more thorough than I would have put together... Thanks! :-)

Geoff Pilling - 3 years, 5 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...