Nim

Take turns removing stones. Whoever takes the last stone wins. There is a secret that always wins. Can you find it?

Play now — no sign-up · Play Nim free

The rules, in four steps.

  1. Three variants: 21 (one pile of 21, take 1–3), Limit (one pile, take up to the number shown) and Piles (several piles, any number from one pile).
  2. On your turn, take at least one stone, all from the same pile.
  3. Whoever takes the last stone wins. There are no draws.
  4. Online games are rated: the variant is drawn at random, and each player has 60 seconds for the whole game.

The oldest maths duel

Nim is one of the oldest strategy games. Two players take turns removing stones, and whoever takes the last stone wins. There is no luck in it: every position is either winning or losing for the player about to move, and the game is about knowing which.

Schools know it as the 21 game. It trains counting back, division with a remainder and, in the version with several piles, binary numbers. On Duelto it is played against a bot with three levels, by two players on one screen, or online against a real opponent for rating.

Three ways to play

21
One pile of 21 stones. Each move takes 1, 2 or 3. The classic starting point, from age 8.
Limit
One pile of 15 to 30 stones and a limit of 3 to 5, shown on screen. Each move takes from 1 up to the limit. The idea of 21, with numbers that change every game.
Piles
Three or four piles of up to 7 stones. A move takes any number of stones, all from one pile. This is classic Nim, and the hardest of the three.

How to get better

Questions

Is there a way to always win at Nim?

From most positions, yes: the player who knows the secret can force a win. Charles Bouton published the full solution for classic Nim in 1901. The bot on Hard plays it perfectly, but every bot game starts from a position you can win, so beating Hard means you have found the secret too.

Is Nim good for learning maths?

Yes. The secret of the 21 game is a lesson in division with a remainder, and classic Nim leads to binary numbers. Teachers have used it for a long time because children want to find the trick by themselves.

How do online games work?

Online games are rated. The variant and the stones are drawn at random, and so is the player who moves first, so nobody can prepare one position. Each player has 60 seconds for the whole game; whoever runs out loses.

Can I play without an account?

Yes. Against the bot and with two players on one screen, Nim needs no account. Online games and the rating need a free one.

Is it free?

Yes. Every game on Duelto is free to play, with no ads inside the game and nothing to buy.

Do I need to download anything?

No. Duelto runs in the browser on a phone, tablet or computer. A free account, made with an email address, is all you need.

Can children play?

Duelto is open from age 8. Accounts for players under 13 are activated by a parent through the confirmation email, and run with extra restrictions.

Other games on Duelto