2026-11-28

Problem — 2026-11-28

Hard

HardLogic

Two players play a game with a single pile of coins. They alternate turns, and on each turn a player must remove exactly 11, 33 or 44 coins from the pile (never more than remain). The player who takes the last coin wins. Both play perfectly. For how many starting pile sizes from 11 to 20262026 inclusive does the second player (the one who does not move first) win?

Enter an integer

Show solution
Call a pile size losing if the player to move loses. 00 is losing; nn is winning iff one of n−1,n−3,n−4n-1,n-3,n-4 is losing. Computing: 00 L, 11 W, 22 L, 33 W, 44 W, 55 W, 66 W, 77 L, 88 W, 99 L, ... The losing sizes are exactly n≡0n\equiv0 or 2(mod7)2\pmod7: from such nn every move lands on residues {6,4,3}\{6,4,3\} or {1,6,5}\{1,6,5\} (all winning), and from any other residue one move reaches 00 or 22 (from 11: take 11; from 33: take 11 or 33; from 44: take 44; from 55: take 33; from 66: take 44). Since 2026=7⋅289+32026=7\cdot289+3, there are 289289 multiples of 77 and 290290 numbers ≡2\equiv2 (2,9,…,20252,9,\dots,2025) in 1..20261..2026: 289+290=579289+290=579.