NIM ZERO · 2026.08.01-v1
Nim winning strategy: leave a zero nim-sum
For finite Classic Nim, a position with nonzero nim-sum has at least one move to zero; a zero position has no move that stays zero. Therefore the winning strategy is to move to zero whenever that option exists.
Find the move
Let S be the XOR of all heaps. For each heap h, compute h XOR S. If that value is smaller than h, reduce h to it. In 3–5–7, S is 1 and 7 XOR 1 is 6, so take one from the third heap.
Know the boundary
This proof applies to normal-play Nim where any positive number may be removed from one heap. Misère Nim changes when only single-piece heaps remain, and Take-away 21 limits each move to 1–3, so those endings use different tests.
Worked position
| Heap | Binary | 10 |
|---|---|---|
| 1 | 011 | 3 |
| 2 | 101 | 5 |
| 3 | 111 → 110 | 7 → 6 |
| nim-sum | 001 → 000 | 1 → 0 |
Method and source
Method: finite legal moves are exhaustively checked by Nim Zero’s pure rules engine. Mathematical source: C. L. Bouton, “Nim, A Game with a Complete Mathematical Theory,” Annals of Mathematics, Second Series 3, no. 1/4 (1901–1902), 35–39.
DOI: 10.2307/1967631 · 2026-08-01