As joriki noted this problem is impossible.
The reason it is impossible is that there are multiple solutions and so the mathematicians would not be able to declare that they had discovered each over's numbers.
The conversation gives us additional constraints on the solutions. In order for mathematician A to declare that there is no way that B could determine his sum that means he has ascertained that:
- His sum is NOT the sum of two primes.
- His sum can never be created using two numbers whose product has a unique factorisation in the interval [2, 20] i.e. 20+20=40, => 20*20=400 (I believe the upshot of this is that the sum must be less than 13 as 13=2+11 and 11*2 = 22 > 20)
(Please note I did the following on paper and may have made a mistake somewhere.)
From the bounds of the problem we know that the possible sums range from 4 to 40 inclusive. Using the first constrain we can eliminate many of these. If take all possible combinations of adding two primes (in the interval [2, 20]) and eliminate those sums we are left with the following as possible sums:
11, 17, 23, 25, 27, 29, 31, 33, 35, 37, 39, 40
Applying constraint 2 we find that the sum must be 11. This allows mathematician B to declare "But I know the sum now!"
In order for there to no unique factorisation we must be able to create the sum (11) using a non-prime in the interval [2, 20]. To find the solutions we must subtract each non-prime from the sum. For each valid solution the result will be in the interval [2, 20]. This leads to the following set of four solutions.
- (4, 7) Product: 28 = 2 * 14.
- (5, 6) Product: 30 = 3 * 10 = 2 * 15
- (3, 8) Product: 24 = 4 * 6 = 2 * 12
- (2, 9) Product: 18 = 3 * 6
Note: joriki's java code is incorrect. Rather than proving that there are no solutions it in fact finds many false positives.
When running the program "can't be determined" is never output meaning the program does find what it believes are solutions.
'j' is not tested to check whether it is in range, creating many false positives.
sum = 15 has a unique factorisation 3*5, but the program counts 2 factorisations in the form of 3*5 & 5*3. This means that nfactorizations ends up being 1 and thus creating a false positive.
Even when these bugs are fixed the program tests for cases such as sum = 7 and finds the solution (3, 4). This also is wrong as mathematician A could not look at the sum, 7 and conclude that mathematician B would not be able to find the sum. This is because 7 can be formed by adding 2 and 5, both of which are prime. B would be able to look at his product of 10 and deduce that the numbers are 2 and 5 and that the sum is 2+5=7.