7
$\begingroup$

Came up with this game, haven't thought of a catchy name for it, but here it goes:

There are $n$ marbles. Two players alternate between taking away $\frac{kn}{p}$ marbles, where $p$ is a prime number (prime divisor of $n$) and $1 \le k < p < n$ ($n$ is the current number of marbles). The players get to choose $p$ and $k$ for each turn.
The first player who can't complete their turn (i.e. when you can't take away a natural number of marbles which can be written as $kn/p$) loses.

For example, let $n = 30$. The starting player can take away $30*2/5 = 12$ marbles, which results in $18$ marbles. No matter what the second player does (take away $18*1/3$, $18*2/3$ or $18*1/2$), they result in winning states for the starting player ($6$, $9$ or $12$). So $n=30$ is a winning state.

The premise is simple, yet I have difficulties with finding a general formula to decide if a game state is winning or losing. I've tried constraining $p$, and managed to find a pattern which was easily provable, but I haven't been able to work it out for all possible $p$.
Other than the obvious (prime numbers are losing states, etc.) I have no clue. I wrote a simple python script to try out all combinations, but that didn't help either.
Any ideas?

$\endgroup$
9
  • 2
    $\begingroup$ Is $n$ the initial number of marbles or the current number of marbles? $\endgroup$
    – joriki
    Jan 1 at 20:34
  • 2
    $\begingroup$ :) We know that it's hard to write good questions. But we're quite happy to help the OP pull the question into shape. We only get upset when OPs don't respond appropriately to our comments. ;) $\endgroup$
    – PM 2Ring
    Jan 1 at 20:38
  • 1
    $\begingroup$ This is a variant of Nim, involving prime factorization. So you could call it Prim. $\endgroup$
    – PM 2Ring
    Jan 1 at 20:41
  • 1
    $\begingroup$ @PM2Ring , I'm not sure if you were joking, but "Prim" is a pre-existing game with different rules defined in the book "Winning Ways for your Mathematical Plays". The game in this question seems similar to, but distinct from, the game "Dim" (remove a divisor) which is defined on the same page of that book. $\endgroup$
    – Mark S.
    Jan 1 at 21:26
  • 1
    $\begingroup$ @MarkS It was just a suggestion. I wasn't aware of the existing game. (I've never read that book, but I have spent some time playing with Conway's FRACTRAN and Life). $\endgroup$
    – PM 2Ring
    Jan 1 at 21:31

1 Answer 1

6
$\begingroup$

Update: I just realized that the solution below ignores your condition $p\lt n$. Due to this constraint, a prime factor can no longer be picked if it’s the only one left. That destroys the independence of the prime factors; they can no longer be considered as piles where you can play independently and whose nim-values can therefore be XORed. I’ll nevertheless try to finish the proof below for the modified (and much simpler) game.


I’ll assume that you know about nim-values (if not, you should read up on them).

Write $n=sp$, with $s\in\mathbb N$. Then taking $\frac{kn}p$ marbles leaves $n-\frac{kn}p=sp-\frac{ksp}p=s(p-k)$ marbles. So what you do in each turn is pick a prime factor and reduce it, leaving all other prime factors unchanged. If you view the prime factors as piles as in the game of Nim, a move consists of reducing one of the piles (leaving at least one object) and then replacing it by piles corresponding to its prime factors.

Thus, the nim-value of a number is the XOR of the nim-values of its prime factors, and all you need for perfect play are the nim-values of the primes. I believe the nim-value of $p_n$ is $n$; I’ll try to post a proof for that shortly.

$\endgroup$
2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .