Skip main navigation

The Game of Nim

Watch Yossi Elran’s video on The Game of Nim
Nim is a two-player game The goal of the game is to take the last stone. Whoever takes the last stone, wins. At the beginning of the game, the players decide on the game’s rules, How many piles of stones there are, and how many stones each player is allowed to take from each pile. Let’s take a look at a game of Nim between two players, with one pile of ten stones, and each player can take as many stones as he likes in his turn. Not a very clever game. The first player will always win by taking all the stones in the pile. But suppose there are ten stones in the pile, and each player can take only up to nine stones?
The first player can take up to nine stones. Suppose he takes exactly nine stones. Now the second player takes the remaining stone and wins the game. Of course, the first player doesn’t have to take nine stones. He can take less, but that won’t change the outcome of the game. The second player wins, regardless. Let’s change the rules. We’ll still keep one pile for the moment, but this time, each player is allowed to take one, two or three stones, but no more. Can we deduce who will win this game - the first player or the second player? Is there a general way to analyse Nim? Read the article to find out…

Hopefully, you’ve watched the video and now understand what Nim is, but if you still have some questions, you can post them in the comments and we will try and answer as soon as we can. Other learners are invited and encouraged to answer as well!

This article is from the free online

An Introduction to Recreational Math: Fun, Games, and Puzzles

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education