*Photo by Windell Oskay via flickr.*

**Math concepts:** logic, patterns, divisibility

**Number of players:** 2

**Equipment:** 10 tokens, any sort, mix or match

## Set Up

Place the pile of tokens (pebbles, toothpicks, beans, pennies, dry cereal, etc.) on the table between the players.

## How to Play

Allow the youngest player choice of moving first or second; in succeeding games, allow the loser of the last game to choose. On your turn, remove one or two tokens from the pile. You must take at least one token on your turn, but you may not take more than two.

## Endgame

Whoever takes the last token is the winner.

## Variations

**1 –** Change the number of tokens in the starting pile.

**2 –** Allow players to take one, two, or three tokens per turn.

**3 –** Make the last token “poison.” Whoever takes it loses the game. This changes the strategy significantly, and it allows for an interesting endgame. My students (especially the boys) love to act out dramatic death scenes when they lose.

## Comments

Players must always agree before starting whether the person taking the last token will win (traditional) or lose (the “poison” variation).

In math club, we start by playing a few games on the chalkboard, the whole class against the teacher. (I give them at least two opportunities to win before I move in for the kill.) Then the kids pair off to play several games against each other, taking turns on who goes first. If anyone thinks he knows the pattern to the game, I let him challenge me — and no “free” chances, this time!

- I let the student choose whether to go first or second. If he muffs that choice, I know he is just guessing.
- If he can’t beat me, he needs to go back to his partner and experiment with different strategies.
- If the student beats me, I add two tokens to the pile. That changes the strategy of the game slightly. If he can still beat me (when I allow him choice of first or second move), then I am pretty sure that he has the game figured out. Time to move on to the “poison” version.

Nim is a favorite game at our math club meetings, but it is like Tic-Tac-Toe in that once you know the trick, you can usually win (unless the other player knows, too). That is boring. For a greater challenge, try the multiple-pile version.

Claim your two free learning guide booklets, and be one of the first to hear about new books, revisions, and sales or other promotions.

Great post! I’m working on an article for my homeschool newsletter about teaching math, and I want to include a link to your blog….it’s very nice.

Glad I found you in the Carnival!

Hi, Barbara. Thank you for the encouraging words!

This was a standby “keep the kids busy while waiting somewhere” game in our family for years. You don’t need counters – just do the mental math.

That’s true, Mia. Nim has so many variations that it is nearly impossible to count them! You can also use a drawing, like circles with flower petals to cross off, or like the Pharaoh’s Pyramid diagram. We played another game in math club, called “5-10-15.” The players take turns adding 5, 10, or 15 points to the running total, and whoever reaches 100 wins the game. It is Nim, again, with adding instead of taking away.

I wrote a version of Nim using Borland International’s “Turbo C” language.

It plays with rows of 7,5,and 3 items. In studying it to write the program, I learned that it is flawed, in that whoever goes first can guarantee a win with perfect play following. As long as the opponent is left with NimSum=0, you will win. NimSum = row1 XOR row2 XOR row3. XOR is binary eXclusive OR. When NimSum != 0, just remove from the row that contributes the most significant bit of NimSum, numbertoremove= otherrowA AND otherrowB.

in the 7-5-3 starting position, 111 XOR 101 XOR 011 = 001. Since all three rows contribute the most significant bit of NimSum, taking one item from any row leaves NimSum=0. Tell me where to send it and I’ll gladly send the console application and the source code.

The game isn’t flawed, exactly. All games of this type — even chess — favor either the first or second player. The favored player can guarantee a win or tie (depending on the game) with perfect play, no matter what the other player does. What makes the game fun is not knowing the strategy, because if you know the outcome in advance, there is no point in playing.

The difference between Nim and chess is that Nim is a simple game. With the 1-pile Nim game, even children can master the strategy. The multi-pile Nim strategy is more difficult, but it can be solved. Even checkers has been solved, but chess is complex enough that the perfect strategy has not been found. Yet.

Oh math! I am beginning to like math more and more.

My favorite version of Nim-like game is harder to analyze. Make 3 piles of ‘stones’. On each turn, the player must pick up at least one stone. They can pick up as many stones as they want from any one pile. Whoever has to pick up the last stone loses. (Or play that whoever picks up the last stone wins.)

Hugh, you might enjoy programming this one.

Hi, Sue! I like your version of the game. It’s difficult enough to enjoy for long-term play, where the Math Club version is meant to be easy so the students can figure it out.

Denise, according to the standard terminology of, say, Berlekamp, Conway, Guy, the game you described is called Scoring and the variant you call

poisonis the misere variant. Both can be played with one or more piles. Nim is always played with more than 1 pile and there is no limitation on how many pebbles a player can remove (but always from a single pile.) Nim has several variants, the most transparent of which I call Plainim. All belong to the category of combinatorial games of which there is a great variety.(I actually thought a way to thank you for your recent note and check whether my rss feeder is OK now.)

I’ve never read the mathematical games books, because my library doesn’t carry them, not even through library loan. (Although, sometimes my librarian can do amazing things, so maybe I should ask her to do a special hunt…) In the teacher-oriented books I’ve read, it seems that most take-away-style games are considered a variant of Nim.