Number Guessing Game
Guess a random number with higher or lower feedback, or let the computer guess yours. Any range, optimal-play counter and a best score kept on your device.
Number guessing game
I have picked a number between 1 and 100.
Still anywhere in the range.
Your guesses
Newest first. The arrow shows which way I sent you.
This round
Change the game
Think of a number between 1 and 100, and do not tell me.
Ready when you are.
How I am narrowing it down
Each answer halves what is left. That is binary search, and it is why a hundred numbers never takes more than seven questions.
My progress
What the Number Guessing Game does
- Any range, with presets from a single digit to 1–1000
- Shows how many numbers your guesses have ruled out
- A reverse mode where the computer guesses yours
- Counts your guesses against what perfect play needs
- Best score kept in your browser, nothing uploaded
Your data stays on your device
The Number Guessing Game runs entirely in your browser. Nothing you enter is uploaded to a server, which means there is no copy of your input anywhere but your own machine. See how that works.
Two ways to play
In the first, a number is picked and you guess. Each guess comes back too high or too low, and the bar shows how much of the range your answers have ruled out — which is the information people usually fail to use.
In the second, you think of a number and the computer finds it by asking yes-or-no questions. It is the more interesting half, because it shows the strategy working: a hundred numbers never takes more than seven questions, and a thousand never takes more than ten.
The strategy, which is just halving
Always guess the middle of what is still possible. Whatever the answer, half the remaining numbers are eliminated. That is binary search, and the number of guesses it needs is how many times you can halve the range before one number is left — the base-two logarithm, rounded up.
So 1 to 100 needs seven guesses in the worst case, not fifty. 1 to 1000 needs ten. A million needs twenty. The counter in the panel shows that figure for whatever range you set, which is the number to beat.
The common mistake is guessing a number already ruled out — after "higher than 50" and "lower than 75", guessing 30 wastes a turn. The tool marks those, because noticing it is most of the skill.
How the number is picked
With the browser's cryptographic random source, and with rejection sampling rather than a remainder. Taking a random 32-bit value modulo the range size makes the first few numbers very slightly more likely, because 2^32 does not divide evenly by, say, 100. The bias is tiny and would never be noticed in a game, which is exactly why it is worth not having: any value landing in the uneven tail is discarded and redrawn.
Nothing about the number, or your guesses, leaves your browser. The best score is kept in your own browser's storage and nowhere else.
Why it feels harder than it is
Most people guess somewhere near the middle for the first turn or two and then start chasing the feedback, moving a few at a time instead of halving again. That turns a seven-guess problem into twenty.
The hint option does not name the number. It tells you the midpoint of the live range and whether the answer is odd or even, which is the same advice as the strategy — because the useful thing to learn here is the method rather than this particular number.
Number Guessing Game questions
The things people ask most about this tool.
What is the fewest guesses needed for 1 to 100?
Seven, in the worst case. Halving the remaining range each time takes 100 to 50 to 25 to 13 to 7 to 4 to 2 to 1, which is seven steps. You can get lucky sooner, but seven is the figure that always works.
How does the computer find my number so quickly?
It asks whether your number is above the midpoint of what is still possible. Either answer removes half the candidates, so the count falls 100, 50, 25, 13, 7, 4, 2, 1. That is binary search, and it is why ten questions cover a thousand numbers.
Is the number genuinely random?
Yes. It comes from crypto.getRandomValues, the browser's cryptographic random source, and any value in the uneven tail of the range is rejected and redrawn so every number is equally likely. A plain remainder would make the lowest numbers marginally more common.
Can I change the range?
Yes, to anything up to a million wide, and there are presets for a single digit, 1–10, 1–100 and 1–1000. Best scores are tracked per range, so a win at 1–10 does not get compared with one at 1–1000.
Where is my best score stored?
In your browser's own storage on this device. There is no account and nothing is uploaded, so it will not follow you to another device, and clearing your site data clears it.
What happens if I answer the computer wrongly?
It will eventually rule out every number and say so, rather than claiming a wrong answer. If that happens, one of the higher-or-lower replies was the wrong way round — start again.
More free tools
Other utilities in the collection, all free and all client-side.
QR Code Generator
Create QR codes for URLs, WiFi, WhatsApp, vCards, and more with custom colors and logo.
Open tool →Word Counter
Count words, characters, sentences, and estimated reading time as you type.
Open tool →Review Request Template Generator
Ask customers for a review with templates for email, SMS and WhatsApp.
Open tool →