Free Number Guessing Game - Guess the Number

Guess the secret number with higher/lower hints. Multiple difficulty levels with score tracking.

What Is Number Guessing Game?

The number guessing game is a classic logic game where the computer picks a random number within a range and you try to guess it. After each guess, you receive feedback: "too high" or "too low". Using binary search strategy (always guessing the middle of the remaining range), you can find any number in 1–100 in at most 7 guesses.

This deceptively simple game teaches binary search — one of the most fundamental algorithms in computer science. It is also a great introduction to logarithmic thinking: the maximum number of guesses needed is log₂(n), so doubling the range only adds one more guess.

The idea of organising data so it can be searched this efficiently goes back much further than computing itself — one of the earliest known examples is a Babylonian clay tablet from around 200 BCE containing roughly 500 sorted numbers and their reciprocals, built specifically to make lookups faster. Binary search as a formal computing algorithm was first documented in 1946, in John Mauchly's Moore School Lectures. The efficiency gap it creates is dramatic at scale: searching a sorted list of 2.5 million items one-by-one could take up to 2.5 million checks in the worst case, but binary search finds the same item in at most about 22 — which is exactly the same principle that lets this game solve numbers up to 500 in just 9 guesses.

How to Play

  1. Select the number range (1–100, 1–500 or 1–1000).
  2. Enter your guess in the input field.
  3. Read the feedback: "Too high", "Too low" or "Correct!".
  4. Use the feedback to narrow down the range and make your next guess.
  5. Try to guess the number in as few attempts as possible.

Tips & Best Practices

  • Always guess the middle of the remaining range — this is the binary search strategy and minimises worst-case guesses.
  • For 1–100, start at 50. If too high, try 25. If too low, try 75. Keep halving.
  • The optimal maximum is 7 guesses for 1–100, 9 for 1–500 and 10 for 1–1000.
  • Track your guess history to avoid repeating numbers.

Common Use Cases

  • Learning binary search through an interactive, intuitive game.
  • Quick mental exercise and number sense practice.
  • Teaching algorithms and logarithmic thinking in computer science education.
  • Fun classroom activity for maths and logic lessons.

Frequently Asked Questions

How many guesses do I get?

All three difficulties are free: Easy (1-50) gives 10 guesses, Medium (1-100) gives 7, and Hard (1-500) gives 9. Premium adds a custom number range, hot/cold hints and a persistent best-score leaderboard.

How is the guess allowance for a custom range calculated?

Premium's custom range uses the standard binary-search-optimal formula (roughly log base 2 of the range, plus a small buffer) — so a 1-20 range requires 7 guesses, keeping every custom range fair rather than arbitrarily easy or hard.

Does my best score survive a page refresh?

Yes, for Premium users — scores are saved to your browser's local storage, not just kept in memory for the current session, so reloading the page does not reset your session stats or best-score history.