How it works
Choose a range, type a guess and press Guess. The game tells you whether to go higher or lower and shows the range that is still possible. Win in as few tries as you can. Your fewest tries for each range is saved on your device.
Maximum tries with the best strategy = ⌈log₂(range + 1)⌉
Examples
About Number Guessing Game
The number guessing game is a classic first programming exercise and a simple way to learn binary search. The computer picks a secret number, and each hint of higher or lower removes half of the remaining possibilities if you guess the middle. This version has three ranges and tracks your fewest tries.
Why play the number guessing game
- A quick game with children to practise number sense.
- Learning how binary search works.
- Settling small decisions with a game.
- Beating your own best number of tries.
Tips to guess faster
- Always guess the middle of the remaining range.
- Use the range shown after each hint.
- For 1 to 100, start at 50.
- Try the 1 to 1000 range once you can win in 7 tries.
Common mistakes
- Guessing numbers outside the range that is still possible.
- Repeating a guess you already made.
- Guessing near the edges instead of the middle.
Frequently asked questions
What is the best strategy?
Always guess the middle of the remaining range. This is called binary search, and it halves the possibilities each time.
How many guesses does 1 to 100 need?
At most 7 with the best strategy.
Is the number really random?
Yes. A new random number is chosen each round using your browser's random generator.
Is my score saved?
Your best score is stored in your own browser only. Nothing is uploaded.