Is there a winning strategy for this number game?

227 Views Asked by At

Given a composite number $N_0$. Player one subtract from $N_0$ one of its prime factors and get the number $N_1$. The player two do the same with the number $N_1$ and so on. The first player to reach a prime number win.

I'm testing machine learning and would like a key solution to compare with the learned skill.

It's a perfectly defined game which is an example of a very general game on graphs that can be generalized to cover almost any game of the kind (even chess). The solution seems to be trivial (for humans), but machine learning programs can without knowing the solution search winning patterns to be compared with the correct solution. 

1

There are 1 best solutions below

16
On BEST ANSWER

Let $W=\{n\in Z_{>2}|\;\; 2|n \wedge \exists p\in\mathbb P_{>2}: p|n \}\cup\{4\}$. Say it's your turn on the position $n\in W$. If you select a move $n-p$ where $p>2$ then the opponent is on an odd number $n-p\notin W$ and must select to subtract an odd prime $q$, where $p|(n-p)$ and $q|(n-p-q)$. But $(n-p-q)\in W$ since it's even with a prime factor $>2$.

By induction you may stay in a path in $W$ and as your number get smaller you will get a position $2r$ where $r\in\mathbb P_{>2}$ and win with the move $2r-r$, if and only if the opponent's odd number doesn't reach a prime befor you do. But the number $n-p-q$ is a prime only if $n-p-q=q$ (since $q|(n-p-q)$), that is if $n-p=2q$ which is impossible since $n-p$ is odd.


There is no winning strategy on an odd number. From an odd number one have to go an even number that's not a power of two. The other player then have a position in $W$ which is possible to keep while subtracting an odd prime from the even number, giving the opponent a position at an other odd non prime number.

Example for start 15 and 20
Losing position: 
15,10,5
   12,9,6,3
Winning position:
20,15 se above.