Guess the Number

Find my number from 1 to 100.

Guesses

0

Still possible

100

Best

—

1100

I'm thinking of a number from 1 to 100.

    Statistics

    RangePlayedBestAverage

    Saved in this browser only. Best and average leave out games where you used Suggest.

    Guess the Number is the classic higher-or-lower number guessing game. The computer picks a secret whole number and tells you after every guess whether the answer is higher or lower, so you can close in on it. Play from 1 to 100, pick a smaller or much bigger range or one of your own, take the guess-limit challenge, or turn the tables and let the computer find the number you're thinking of. It's free, it runs in your browser, and it's a hands-on lesson in one of the most useful ideas in computing.

    How to play

    1. Choose a range. 1 to 100 is the classic; 1 to 10 suits younger players and 1 to 1,000,000 is a real test.
    2. Type a whole number and press Guess or Enter. Phones show a number pad.
    3. Read the hint. Too low means the secret is higher; too high means it's lower. The bar and the Still possible count shrink to the numbers that fit every hint so far.
    4. Keep going until you hit it. Each guess appears as a chip with an arrow pointing toward the answer.
    5. At the end, the game shows your guesses next to the ones perfect halving would have made for the same number.

    Let the computer guess your number

    Switch to Computer guesses, think of a number in the range (write it down if you like) and press I've got a number. Answer each guess with Higher, Lower or Correct. The computer always guesses the middle of what's left, so on 1 to 100 it never needs more than seven guesses. If your answers stop adding up, it says so: no number can be higher than 36 and lower than 38 without being 37.

    How many guesses does it take?

    If every guess lands in the middle of the numbers that are still possible, each hint throws away half of them. The table shows the most guesses that strategy can ever need for each range, and the average over every possible secret number.

    RangeNumbersMost guessesAverage
    1 to 101042.9
    1 to 505064.9
    1 to 10010075.8
    1 to 1,0001,000109.0
    1 to 10,00010,0001412.4
    1 to 1,000,0001,000,0002019.0

    Notice how slowly the guesses grow: ten times as many numbers costs only about three more guesses. That's because each guess doubles what halving can cover. Seven guesses can tell apart 2⁷ − 1 = 127 numbers, enough for 100; twenty can tell apart more than a million.

    Binary search, step by step

    Suppose the secret is 37. Halving guesses 50 (too high, so 1 to 49 is left), then 25 (too low, so 26 to 49), then 37: found in 3 guesses with some luck. The unluckiest number for this strategy is 100, which takes the full seven: 50, 75, 88, 94, 97, 99, 100. To find the middle yourself, add the lowest and highest numbers still possible and halve the total, rounding down: (1 + 100) ÷ 2 = 50.5, so 50.

    Computers use exactly this idea, called binary search, to find an entry in a sorted list without reading every item. Each higher-or-lower answer works like one binary digit, which is why the most guesses you can need equals the number of digits in the range size written in binary: 100 is 1100100, seven digits. Try it with the number base converter.

    The guess-limit challenge

    Tick Limit me to … guesses and you only get as many guesses as perfect halving could ever need: 7 for 1 to 100, 10 for 1 to 1,000, 20 for 1 to 1,000,000. Play the middle every time and you can't lose; guess on a hunch and you might run out. It's a good way to check that the strategy has really sunk in.

    Tips and common mistakes

    • Open in the middle. 50 for 1 to 100, 500 for 1 to 1,000. On 1 to 100 any opener from 37 to 64 still guarantees 7 guesses; open with 36 or lower, or 65 or higher, and the worst case becomes 8.
    • Use the bar, not your memory. The highlighted part shows exactly which numbers are left; guessing outside it wastes a guess, and the summary counts how often you did.
    • Ignore hunches. Every number is equally likely, so favorite numbers, round numbers and "it was low last time" don't help.
    • Accept the luck. Halving guarantees the worst case, not a miracle. Beating the average means the secret happened to fall on one of your early midpoints.
    • Repeats are free here. Typing the same number twice doesn't cost a guess; the game just repeats the hint.

    In the classroom

    The game practices comparing numbers, finding a midpoint and reasoning with inequalities: after "higher than 40" and "lower than 60", the answer x satisfies 40 < x < 60. With older students, the table above is a friendly way into powers of two and logarithms (for n numbers, the most guesses needed is log₂(n + 1), rounded up). The custom range works with negative numbers too, and the computer-guesses mode makes a good demonstration on a projector. For a classroom draw or a quick random pick, use the random number generator.

    More number games: Higher or Lower asks you to judge the odds on the next playing card, Bulls & Cows is a code-breaking game played with digits, and Math Blitz drills mental arithmetic against the clock. All the free games run in your browser.

    Frequently Asked Questions

    What is the best strategy for Guess the Number?

    Always guess the middle of the numbers that are still possible. Start with 50 on 1 to 100; if the answer is higher, try 75, and if it's lower, try 25. Each guess throws away at least half of what's left. This is called binary search, and the Suggest button does the arithmetic for you.

    How many guesses does it take to find a number from 1 to 100?

    Never more than seven if you always guess the middle of the possible range, because seven halvings can tell apart up to 127 numbers (2⁷ − 1) and 100 is fewer than that. Played that way, the average game takes 5.8 guesses.

    How many guesses for 1 to 1,000 or 1 to 1,000,000?

    At most 10 for 1 to 1,000 and at most 20 for 1 to 1,000,000. Each extra guess doubles how many numbers halving can cover, so even a range of two billion numbers needs no more than 31.

    Can the computer guess my number?

    Yes. Switch to Computer guesses, think of a number in the chosen range, and answer each guess with Higher, Lower or Correct. The computer always guesses the middle of what's left, so it never needs more than seven guesses for 1 to 100.

    What happens if I give the computer a wrong answer?

    It notices as soon as the answers stop adding up. If you've said your number is higher than 36 and lower than 38, it can only be 37; saying it isn't leaves no number at all, so the game points out the contradiction and offers to start over.

    Is the secret number really random?

    Yes. Each game picks a whole number with your browser's random number generator, and every number in the range is equally likely. There's no favorite number to exploit, which is why halving is the best you can do.

    Do repeated or impossible guesses count?

    Guessing the same number twice is free: the game reminds you of the answer and doesn't count it. A new number outside what's still possible does count, because it's a real guess, and the summary at the end tells you how many of those you made.

    What is the guess-limit challenge?

    Tick Limit me to … guesses and you only get as many guesses as perfect halving could ever need: 7 for 1 to 100, 10 for 1 to 1,000. Play the midpoint every time and you can't lose; one careless guess and you might.

    Can I choose my own range?

    Yes. Pick Custom range and type any two whole numbers between −1,000,000,000 and 1,000,000,000, negatives included. The game works out the guess limit and the binary-search numbers for whatever range you choose.

    Is my best score saved?

    Yes, in this browser. The statistics button shows games played, your fewest guesses and your average for each range. Games where you used the Suggest button count as played but don't set a best. Nothing is uploaded.

    Is Guess the Number good for teaching math?

    It's a hands-on way to practice comparing numbers, finding a midpoint, and thinking in ranges and inequalities. Older students can connect it to powers of two, logarithms and the binary search algorithm used in computer science.