Two persons A and B are each wearing a hat with a number written on it. Neither A nor B can see the
number on their own hat but they can see the number on the other’s. A sees number 5 on B’s hat and
B sees number 4 on A’s hat. They are told that A has the product of two positive integers written on
her hat and that B has the sum of the same two numbers written on her hat.
First B is asked whether she knows for sure what the two numbers are. If her answer is ‘no’, A is
asked the same question and so on until someone answers ‘yes’. Assuming that both are perfect
logicians and answer