I do not agree with your solution to this problem. It is true that if B saw a number on A's hat that was the product of two primes, B could determine the number on B's own hat, so if the number on B's hat were expressible as the sum of two primes, A could not conclude that B could not determine the number on B's own hat. On the other hand, the number on B's hat could be expressible as the sum of a power of 2 and a prime. For example, the number on B's hat could be 13 = 8 + 5. If the number on A's hat were 40 = 8 + 5, B would still not know whether the number on B's own hat was 13 = 8 + 5 or 14 = 10 + 4. After A declared that B could not determine the number on B's own hat, then B could conclude that the number on B's own hat could not be 14, since then the number on A's hat could have been 33 = (3)(11), which would have allowed B to determine that the number on B's own hat must be 14 = 3 + 11. The trouble with the proposed solution (A has 438 on his hat and B has 149) is that although A can make his first statement, B cannot subsequently conclude that his number must be 149. Since the prime factors of 438 are 2, 3, and 73, B can see that the possible values of x and y such that xy = 438 and both x and y are greater than 2 are (x, y) = (3, 146) and (6, 73). So he knows that the number on his hat must be 149 or 79. But in either case, A could have concluded that B could not determine the number on B's own hat, because for both cases, for all possible values of x and y such that x + y equals the number on B's hat and both x and y are greater than 2, xy cannot be expressed uniquely as the product of two integers both greater than 2. So B cannot determine whether the number on B's own hat is 149 or 79. I still believe that the correct solution to the problem is: A has 208 on his hat and B has 29. A knows that the possible values for (x, y) range from (3, 26) through (14, 15) and so there are 12 possible values for the number on his hat: 78, 100, 120, 138, 154, 168, 180, 190, 198, 204, 208, 210. Since none of these numbers can be expressed uniquely as the product of two integers both greater than 2, A can correctly tell B that B could not have determined the number on B's own hat, that is, before A informed B of this fact. Since the prime factors of 208 are 2, 2, 2, 2, and 13, B can see that the only possible values of x and y such that xy = 208 and both x and y are greater than 2 are (x, y) = (4, 52), (8, 26), and (16, 13). So B knows that the number on his hat must be 29, 34, or 56. But before A tells B that B cannot determine the number on B's hat, B still cannot know whether the number on his hat is 29, 34, or 56. It is true that if it were 34, B could conclude that A would have to allow the possibility that the number on A's hat could be (3)(31) = 91, which would allow B to determine the number on B's own hat, but A has not yet told him that he cannot do so. After A has told B that B cannot determine the number on B's hat, then B can conclude that the number on B's own hat must not be expressible as the sum of two primes and so must be 16 + 13 = 29. Of course, once A has this information from B, A can determine that for each of his 12 possible numbers except one, there is more than one (x, y) pair such that if x + y were on B's hat, A could have concluded that B could not determine the number on B's hat. For example, if 78 were on A's hat, B would not have been able to determine whether the number on B's own hat was 3 + 26 = 29 or 6 + 13 = 19, because A would have been able to make the same statement in either case. Only 208 allows B to determine the number on B's own hat, and so A can conclude that that must be the number on A's own hat. Thomas Turnbull