# A deduction question for perfect logicians

A colleague of mine recently messaged me a riddle. It is about a deduction process between two perfect logicians.

The riddle is as follows:

A person writes two non-zero digits on a paper. He tells person A the product of the digits, and person B the sum of the digits. The both persons have the following conversation:

A: "I don't know the digits"

B: "I don't know the digits"

A: "I don't know the digits"

B: "I don't know the digits"

A: "I don't know the digits"

B: "I don't know the digits"

A: "I don't know the digits"

B: "I don't know the digits"

Then person A says "I know the digits"

From this conversation I'm supposed to obtain the digits which were written. I can express this as a mathematical statemente but I lack the idea of how to deduce this riddle.

I know that the first person chose two numbers $x,y\in [9]:=\{1,\cdots,9\}$ and that person A knows $x+y$ and person B knows $xy$. If $x,y$ are different then $x+y \le 17$ and $xy\le 72$. Otherwise, $x+y\le 18$ and $xy\le 81$.

Now I think I must search for numbers below 81 such that any of $[9]$ divides. Definitely any prime is not such a number and I'm sure there are a couple more. Also, for numbers below 18, it is possible to count the partitions of each number reducing the number of cases which $x,y$ can meet.

I think that this is not a correct approach to this problem and I would like to hear a good approach, albeit without giving the complete answer if possible. Also if there is anything wrong with my reasoning, please tell me so I can correct it.

• $A$ knows $xy$, while $B$ knows $x+y$ according to the question. – Hirak Nov 24 '17 at 6:31
• OP knows that ;) – Cornman Nov 24 '17 at 6:38
• I hate to be obvious here… Could the key to the problem be how many times the line is repeated? If the logicians are perfect, they’ll use the fastest method possible to communicate the data each has to the other. – gen-z ready to perish Nov 24 '17 at 6:46
• Yes! My thoughts go along the lines of: Person A knows "such and such" are all the possibilities of the numbers then since A knows, B reduces the amount of his possibilities. Since there are many (9) deductions in total, that might tell me something as well. But I can't yet grasp it. – Ignacio Rojas Nov 24 '17 at 6:51
• They'll never be able to deduce $ab$ from $ba$ so we know it must be $aa$ or $a0$. If it is $aa$ then B is given an even number A is given a square. If it is $aa\ge 22$ B will always have the possibility is was an ab so A never knowing will never tell him anything. So B not knowing will not tell A anything. So it was $a0$. And as B being told an even number greater than 4 will never let B know, we know that didn't happen. I think it can be deduced from there. – fleablood Nov 24 '17 at 7:41

We may suppose that $x\ge y$.

A: "I don't know the digits", so we see that $(x,y)$ is either of the followings where red numbers, green numbers represent $xy,x+y$ respectively :

$\qquad\qquad\qquad$

B: "I don't know the digits", so we see that $(x,y)=(2,2),(9,4),(6,6)$ were impossible since each of $\color{green}{4,12,13}$ appears at only one place.

A: "I don't know the digits", so we see that $(x,y)=(4,1)$ was impossible since $\color{red}{4}$ appears at only one place.

B: "I don't know the digits", so we see that $(x,y)=(3,2)$ was impossible since $\color{green}{5}$ appears at only one place.

A: "I don't know the digits", so we see that $(x,y)=(6,1)$ was impossible since $\color{red}{6}$ appears at only one place.

B: "I don't know the digits", so we see that $(x,y)=(4,3)$ was impossible since $\color{green}{7}$ appears at only one place.

A: "I don't know the digits", so we see that $(x,y)=(6,2)$ was impossible since $\color{red}{12}$ appears at only one place.

B: "I don't know the digits", so we see that $(x,y)=(4,4)$ was impossible since $\color{green}{8}$ appears at only one place.

A: "I know the digits", so we see that $(x,y)=(8,2)$ was possible since $\color{red}{16}$ appears at only one place, and that $(8,1),(9,1),(4,2),(9,2),(3,3),(6,3),(8,3),(6,4)$ were impossible since if $(x,y)$ were either of them, then A would have said "I don't know the digits").

It follows that the written digits are $2$ and $8$.

• Thanks for your help, with help of Adam's answer and Robb's comment I understood why you excluded 5 and 7. Very nice deduction! – Ignacio Rojas Nov 25 '17 at 16:44

To illustrate a possible approach, let's consider the simpler case in which the digits are limited to $1,2,3,4,6,8$. (It's convenient for illustrative purposes to omit the primes $5$ and $7$ but include the composites $6$ and $8$).

The possible products told to A are $1,2,3,4,6,8,9,12,16,18,24,32,36,48,64$. The only products which can be formed in more than one way, and in brackets the corresponding implied sums, are: $$4 = 1*4 = 2*2\quad (5,4)$$ $$8 = 1*8 = 2*4\quad (9,6)$$ $$12 = 2*6 = 3*4\quad (8,7)$$ $$16 = 2*8 = 4*4\quad (10,8)$$ $$24 = 3*8 = 4*6\quad(11,10)$$

So if A says "I don't know ..." B will know the product must be one of $4,8,12,16,24$. Note the assumptions here and below that B knows that A knows the product, A knows that B knows the sum, and both always say the truth.

If B then says "I don't know ...", the sum must be either $8$ or $10$, the only sums which occur above more than once. The possible products are therefore $12,16,24$.

If A again says "I don't know ...", the product cannot be $12$ or $24$, as the only product with possible sums $8$ and $10$ is $16$.

So B can then say "I know the digits" ($(4,4)$ if the sum is $8$, $(2,8)$ if it's $10$).

This sort of approach with digits $1,\dots,9$ should solve the riddle, although the details will probably be quite tedious.

• $5$ and $7$ cannot contribute to the list of products which can be formed in more than one way but $9$ can. You add in products $9$ and $18$ with sums $(10,6)$ and $(11,9)$ These sums duplicate some of the ones on the list, which explains why it takes longer to get to an answer. – Ross Millikan Nov 24 '17 at 15:15