Guess the Number

Runs in your browser — nothing is uploaded

The computer picks a secret number. Type a guess and it tells you whether the number is higher or lower. How few guesses do you need?

Then swap roles: think of a number and the computer finds it by always guessing the middle of what's left. It never needs more than 7 guesses for 1 to 100, and the game shows why.

How to use it

  1. Choose “I guess” or “The computer guesses”, and a range: 1–10, 1–100 or 1–1000.
  2. In “I guess”, type a number and press Guess. The arrow tells you to go higher or lower.
  3. In “The computer guesses”, think of a number, press “I'm ready” and answer each guess with Higher, Lower or Correct.
  4. Try to match the computer: the best strategy always guesses the middle of the remaining range.

Common uses

  • A simple number game for young children practising “bigger” and “smaller”.
  • Teaching halving and the idea behind binary search in a maths or computing lesson.
  • A quick game for two at home: one thinks of a number, the other guesses.
  • Practising estimation and logical thinking.

Examples

RangeGuesses that always suffice
1–104
1–1007Each guess halves the range: 100 → 50 → 25 → 12 → 6 → 3 → 1.
1–100010

Frequently asked questions

What is the best strategy?

Always guess the middle of the numbers that are still possible. Each answer then rules out half of them, so for 1 to 100 you need at most 7 guesses.

How does the computer guess my number?

It keeps track of the lowest and highest numbers still possible and always guesses the middle one. This method is called binary search and is how computers find items in sorted lists quickly.

What if I give a wrong answer?

If your answers contradict each other, the computer notices that no number fits and says so. Then you can start again.

Why 7 guesses for 100 numbers?

Seven halvings can tell apart up to 2⁷ − 1 = 127 numbers, which covers 100. For 1 to 1000 you need 10, because 2¹⁰ − 1 = 1023.