Nim Game Play the Classic Math Strategy Game Online

Step 1: Choose your opponent, rule and start

0You / Player 1
0Computer

Step 2: Pick sticks from one row, then press Take sticks

© 2004–2026 QuickOnlineTips. Free to use here, but please don’t copy, republish or sell this game. Terms of use

Share this game

Did you like this game? Help us improve it

Want to tell us more? Contact us

★ Black Friday★ Cyber MondayWeb hosting up to 85% off, checked on each host’s own siteGrab the deals →

About this game

Play the Nim game, one of the oldest strategy games in the world, free online. Sticks are laid out in rows. On your turn, take as many sticks as you like from any one row. In the classic version, whoever is forced to take the last stick loses. Play a friend, or take on a computer that plays perfectly on hard.

Quick answer: Click a stick to select it and every stick to its right in that row, then press Take. You must take at least one stick, from one row only. With “Last stick loses”, leave your opponent the final stick. With “Last stick wins”, grab it yourself.

How to play the Nim game

  1. The classic start has four rows of 1, 3, 5 and 7 sticks.
  2. Players take turns. On your turn, remove one or more sticks from a single row.
  3. In the standard (misère) game, the player who takes the last stick loses. You can switch to “Last stick wins” too.

The secret winning strategy

Nim was completely solved by the mathematician Charles Bouton in 1901. Write each row size in binary and add the columns without carrying (this is called the XOR or nim-sum). If the nim-sum is zero after your move, you are in a winning position, because whatever your opponent does, you can make it zero again.

RowSticksBinary
11001
23011
35101
47111
Nim-sum000

The classic 1-3-5-7 start has a nim-sum of zero, so the player who moves first is at a disadvantage against perfect play. In the “last stick loses” version, play the same way until only rows of one stick remain, then leave an odd number of single sticks.

Nim tips for beginners

  • Pairs cancel out. Two equal rows always have a nim-sum of zero, so mirror your opponent’s moves on them.
  • Count single sticks at the end. In last-stick-loses, you want your opponent to face an odd number of single sticks.
  • Practice on easy first, then switch to hard and see if you can find the winning moves.

Like strategy games? Try dots and boxes, checkers or tic tac toe. For number practice, there is the times tables game.

FAQ

Can I beat the computer on hard?

Yes, if you start from a position with a nim-sum other than zero and never make a mistake. Try “Random rows” and go first.

Is Nim good for teaching math?

Yes. It is a fun way to introduce binary numbers, XOR and game strategy, and kids enjoy trying to beat the computer.

Found this useful? Share it with someone who needs it.

100 Tech Terms ebook cover

Subscribe to our weekly tech newsletter

Free: 100 Tech Terms ebook (worth $2.99)

Unsubscribe anytime. Privacy

Latest Tech Guides