2

If $A$ and $B$ are playing a game in which they have a number $n \geq 2$ and take turns dividing it with $p$ or $p^2$ for some prime $p \mid n$ such that whoever lands on $1$ after the series of divisions wins the whole game. If $A$ is given the start, find who has a better winning chance.

And, we can generalize the problem for $p$ or $p^2$, $\cdots$ or $p^k$ for some $k\leq n$ as well. How?

In this problem, it seems we have to do a backward approach. Like, the winner will be left with some prime $q$ or its square ($q^2$), which means, the loser was previously left with $qp$ or $q^2p$. How to proceed? Like, any hints?

I know that this is a variant of the Nim game. But when this problem is given, what's the intuition behind it? How would someone come up with that algorithm? (The winning strategy)

Mathejunior
  • 3,344

1 Answers1

0

Approach

First, to analyze a game like this, you need to know about the Sprague-Grundy Theorem and the strategy for Nim. You can find a list of resources other than Wikipedia at this Community Wiki answer.

Note that since every move involves decreasing the power of some particular prime factor of $n$, the various primes are independent, and a game like $p^7q^3$ is the disjunctive sum of the games $p^7$ and $q^3$. Therefore, by Sprague-Grundy and the strategy for Nim, it suffices to find the Grundy/nimber values for a single power $p^m$.

When we divide $p^m$ by $p^i$ for $1\le i\le k$, we are basically just subtracting $i$ from $m$. So this game is really a "subtraction game" where we have numbers (the exponents of the primes) and take turns subtracting some amount in a specified set ($\{1,\ldots,k\}$) from a single number. This particular subtraction game is well known, since the subtraction set of $\{1,\ldots,k\}$ gives a particularly nice pattern. (In fact, every subtraction game has an eventually-periodic pattern of Grundy/nimber values for a single heap.)

Answer

As mentioned on Wikipedia, you can play this subtraction game just like Nim except you should think of the "heap sizes" (the exponents of the primes) modulo $k+1$.

Examples

For example, if $k=2$ as you originally set, then $288=2^53^2$ is a losing position: The second player can respond to a division by $3$ or $3^2$ by dividing by $2$ or $2^2$, respectively. The second player can respond to a division by $2$ or $2^2$ by dividing by $2^2$ or $2$, respectively.

The sequence of losing positions with $k=2$ agrees with Sloane's A036436 up to $46$ (and A036455 if you ignore the $1$), but $48=2^43^1$ is a losing position because when you reduce the powers modulo $2+1=3$ you get the (normal play) losing Nim position $(1,1)$.

The losing positions from $1$ through $1000$ are:

1, 6, 8, 10, 14, 15, 21, 22, 26, 27, 33, 34, 35, 36, 38, 39, 46, 48, 51, 55, 57, 58, 62, 64, 65, 69, 74, 77, 80, 82, 85, 86, 87, 91, 93, 94, 95, 100, 106, 111, 112, 115, 118, 119, 120, 122, 123, 125, 129, 133, 134, 141, 142, 143, 145, 146, 155, 158, 159, 161, 162, 166, 168, 176, 177, 178, 183, 185, 187, 194, 196, 201, 202, 203, 205, 206, 208, 209, 210, 213, 214, 215, 216, 217, 218, 219, 221, 225, 226, 235, 237, 247, 249, 253, 254, 259, 262, 264, 265, 267, 270, 272, 274, 278, 280, 287, 288, 291, 295, 298, 299, 301, 302, 303, 304, 305, 309, 312, 314, 319, 321, 323, 326, 327, 329, 330, 334, 335, 339, 341, 343, 346, 355, 358, 362, 365, 368, 371, 377, 378, 381, 382, 384, 386, 390, 391, 393, 394, 395, 398, 403, 405, 407, 408, 411, 413, 415, 417, 422, 427, 437, 440, 441, 445, 446, 447, 451, 453, 454, 456, 458, 462, 464, 466, 469, 471, 473, 478, 481, 482, 484, 485, 489, 493, 496, 497, 501, 502, 505, 510, 511, 512, 514, 515, 517, 519, 520, 526, 527, 533, 535, 537, 538, 542, 543, 545, 546, 551, 552, 553, 554, 559, 562, 565, 566, 567, 570, 573, 579, 581, 583, 586, 589, 591, 592, 594, 597, 611, 614, 616, 622, 623, 626, 629, 633, 634, 635, 640, 649, 655, 656, 662, 667, 669, 671, 674, 676, 679, 680, 681, 685, 687, 688, 689, 690, 694, 695, 696, 697, 698, 699, 702, 703, 706, 707, 713, 714, 717, 718, 721, 723, 728, 729, 731, 734, 737, 744, 745, 746, 749, 750, 752, 753, 755, 758, 760, 763, 766, 767, 770, 771, 778, 779, 781, 785, 789, 791, 793, 794, 798, 799, 800, 802, 803, 807, 813, 815, 817, 818, 831, 835, 838, 842, 843, 848, 849, 851, 858, 862, 865, 866, 869, 870, 871, 878, 879, 886, 888, 889, 891, 893, 895, 896, 898, 899, 901, 905, 910, 913, 914, 917, 918, 920, 921, 922, 923, 926, 930, 933, 934, 939, 943, 944, 945, 949, 951, 952, 955, 958, 959, 960, 965, 966, 972, 973, 974, 976, 979, 982, 984, 985, 989, 993, 995, 998, 1000

Mark S.
  • 23,925