The whole game in 4 pictures
That's it. You're ready.
Start with a pile
Every game starts with 10–30 sticks on the table.
Take 1, 2 or 3
On your turn, remove 1, 2 or 3 sticks. Your choice.
Swap turns
Your opponent does the same. The pile shrinks fast.
Last stick loses
Whoever has to take the final stick loses the game.
Fine print: You must take at least one stick on your turn. You cannot take more sticks than remain in the pile.
- ~1 minper game
- 0sign-ups needed
- 1v1online, or vs a bot
- 1 trickthat wins every time. Find it.
Winning Strategy
There's a trick that wins every time.
Nim is a solved game, meaning there is a known perfect strategy. Can you spot it before you peek?
Reveal the trickHide the trick
- 1
- 5
- 9
- 13
- 17
- 21
- 25
- 29
The Key to Winning: Try to leave your opponent with a pile size of 1, 5, 9, 13, 17, 21, 25, or 29 sticks.
The winning positions are numbers that are one more than a multiple of 4. These positions are called "safe positions" because they guarantee a win with perfect play.
- If you can leave your opponent with a multiple of 4 plus 1 sticks, do so.
- If you can't achieve this position, take 1 stick and hope your opponent makes a mistake.
- Always think one move ahead to anticipate your opponent's options.
Game Variations
There are several variations of Nim played around the world:
Standard Nim (normal play)
The player who takes the last stick wins.
Misère Nim
The player who takes the last stick loses. This is the version Nim Rush plays.
Multi-pile Nim
The game starts with multiple piles, and players can take any number of sticks from a single pile.
History of Nim
Nim has a rich history dating back centuries:
- Ancient
Ancient Origins
Similar games have been played in China, Japan, and Europe for thousands of years.
- 1901
Modern Name
The name "Nim" was coined by mathematician Charles L. Bouton in 1901, who also published the complete mathematical solution to the game.
- 1951
First Computer Game
In 1951, the NIMROD computer was built specifically to play Nim, becoming one of the first electronic games ever created.
- Today
Mathematical Significance
Nim holds an important place in combinatorial game theory and has been studied extensively by mathematicians.
Today, Nim remains popular as both a recreational game and a teaching tool for mathematical concepts.
Ready for your first round?
We'll match you with someone online. Nobody around? Play the bot.