Who will find the number on their own hat first?

Both $A$ and $B$ have numbered hats on their heads. $A$ and $B$ both cannot see his/her own hat, but they can see other one's hat. $A$ sees number on $B$'s hat as $5$ and $B$ sees $A$'s number as $4$. Both $A$ and $B$ have been informed that $A$'s number is multiplication of two positive integers and $B$'s number is addition of those two integers.

First $B$ is asked that whether he/she knows the two numbers on their hats? If the answer is "No", Then the same question is asked from $A$. Likewise this question is repeatedly asked from both $A$ and $B$ until one says "I know". Suppose that both $A$ and $B$ are ideal super genius. Who will first say "I know" and At which question?

• Are the participants aware that their numbers are different from each other, or must they consider the possibility of having the same number? Also, must the two integers be distinct? – Irishpanda Feb 19 '16 at 16:55
• Seems like a variation of this question. – Rob Watts Feb 19 '16 at 21:57

          +-----+                    +-----+
|  4  |                    |  5  |
| mul |                    | add |
--+-----+--                --+-----+--
| ° ° |                    | ° ° |
|  A  |                    |  B  |
\___/                      \___/


First question to B

$B$ sees a $4$ on $A$'s hat which is the product of 2 positive integers. There are 2 possibilities:

• $1*4$ which means the sum on $B$'s hat would be $1+4=5$
• $2*2$ which means the sum on $B$'s hat would be $2+2=4$

There is no unique solution therefore $B$ must answer "No".

First question to A

$A$ sees a $5$ on $B$'s hat which is the sum of 2 positive integers. There are 2 possibilities:

• $1+4$ which means the product on $A$'s hat would be $1*4=4$
• $2+3$ which means the product on $A$'s hat would be $2*3=6$

Again no unique solution, but $A$ is not done yet. He has to check the thoughts of $B$ during his first question for each of the possibilities.

First question to A - Assuming A's number is a 4, what were B's thoughts?

We saw the possibilities for that already, and know there was no unique solution. Therefore $A$ knows that $B$ would answer "No" and must assume that a $4$ on his hat is possible.

First question to A - Assuming A's number is a 6, what were B's thoughts?

Assuming $B$ sees a $6$ on $A$'s hat which is the product of 2 positive integers, there are 2 possibilities again:

• $1*6$ which means the sum on $B$'s hat would be $1+6=7$
• $2*3$ which means the sum on $B$'s hat would be $2+3=5$

Again no unique solution, so $B$ would have to answer "No" and $A$ must assume that a $6$ on his hat is possible as well.

This means that from $A$'s point of view his hat can be either $4$ or $6$. No unique solution, so he must answer "No".

Second question to B

The possibilities for the number on $B$'s hat from $B$'s point of view are still the same: $5$ or $4$. But now he also knows $A$'s answer for his first question, so he has to analyze his thoughts as well.

Second question to B - Assuming B's number is 5, what were A's thoughts?

Again we know that already, and $B$ will come to the same conclusion. That a $5$ on his hat is possible.

Second question to B - Assuming B's number is 4, what were A's thoughts?

Assuming $A$ sees a $4$ on $B$'s hat which is the sum of 2 positive integers, there are 2 possibilities again:

• $1+3$ which means the product on $A$'s hat would be $1*3=3$
• $2+2$ which means the product on $A$'s hat would be $2*2=4$

2 possibilities, but $B$ must also analyze $A$'s thoughts based on $B$'s first answer. If $A$ would assume a $3$ on his hat, there would be only one possibility for a product ($1*3$). Therefore $A$ would know that $B$'s answer would be "Yes" during the first question. As this was not the case $A$ knows there can be no $3$ on his hat. Therefore $A$ would know there is a $4$ on his hat, which is a contradiction, because $A$ answered "No".

Now $B$ knows that there is no $4$ on his hat. There is only one possibility left ($5$) and he can answer "Yes".

B finds his number first.

Explanation:

A knows the two numbers are either 1 & 4 or 2 & 3, because those are the only positive integers that add to 5. So A knows his number is either 4 or 6.
B knows the two numbers are either 1 & 4 or 2 & 2, because those are the only positive integers whose product is 4. So B knows his number is either 5 or 4.
If B saw a 6, he would know that his number was either 7 (6 + 1) or 5 (2 +3).
If A saw 4, he would know that his number was 4 or 3.

So the questioning begins:

1. B is asked if he knows his number. He doesn't, so he says "no."
2. A is asked. A knows that B sees either 6, 4. Neither of those alone gives B enough information to know his number, so A says "no."
3. B is asked. B knows that if A saw a 4, A would know his own number was 3 or 4. But if A's number had been 3, then B could only be 4, and B would have answered right away in the first round. So B knows that A knows that A is not a 3. So B he knows his number is not 4, so it must be 5. "Yes! It is 5!"

• If A saw 4, wouldn't he only know that his number must be 3 or 4? How does he for sure know it's 4. – mchoy25 Feb 19 '16 at 17:58
• If his number was 3 (or any prime), B would necessarily know that his own was 4 (or $A+1$) since the only option for the two positive integers added or multiplied are $A$ and $1$. – Matt Feb 19 '16 at 18:00
• Hmm. I think I got distracted in the midst of writing my answer. I will edit it. Thank you. – Solocutor Feb 19 '16 at 18:00

Presuming the stipulations I mentioned in my comment above (the two integers are distinct and we cannot have the same number on both hats):

B gets it at the second question. B knows that his number is an addition of two of the factors of 4. This means the only possibilities are 4 and 5. Since we are assuming we can't have the same number on both hats, the only possibility is 5.

EDIT:

Without restrictions:

A gets on on round 3. A knows his possible numbers are 4 and 6. He passes on question #1. B knows his possibilities are 4 and 5. He does not have enough info to eliminate one, so he passes as well. Now, if A's number was 6, B would realize on round 2. In that case, B's possibilities would have been 5 and 7, and had it been 7, A would have got it on round 1 (7 is prime and only has 1 and 7 as factors. A's number could only be 8 in that case), since A did NOT, then the only choice left for B was 5. Since this was not the case, A knows his number is not 6, and therefore can only be 4.

• I'm pretty sure that one of them can figure it out even if integers and hat numbers can be the same. – Zandar Feb 19 '16 at 17:26