Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.
  1. the person will think a number between 1-100. The Questionnaire can ask n number of condition, i.e the number is even or odd, the number is perfect square or prime number, sum of squares etc.
share|improve this question

closed as off-topic by Najib Idrissi, quid, mfl, graydad, ncmathsadist Mar 21 at 19:09

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – Najib Idrissi, quid, mfl, graydad, ncmathsadist
If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

It is certainly possible to find a number between 1 and 100 by asking 100 questions, namely:

  1. Is the number one?

  2. Is the number two?

    etc., etc., etc.

It is possible to do it with 7 questions by binary search. Writing the number in base 2, ask:

  1. Is the units bit one?

  2. Is the twos bit one?

  3. Is the fours bit one?

    etc., etc., etc.

I don't know anything about Java code, but that's for a different website, anyway.

share|improve this answer
2  
Indeed, even 7 questions of the form "Is the number greater than $x$?" will do. (Hint: start with $x=50$.) The binary expansion technique does, however, have the advantage that you can decide all the questions you will ask in advance. –  Ilmari Karonen Mar 20 '12 at 12:51
    
thank you for response –  praveen Mar 21 '12 at 13:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.