A friend of mine told me the following puzzle and I could not solve it.

Sam chooses a positive integer $x$, and Peter chooses another number $y$. They do this secretly, so that Peter does not know Sam's number and vice versa.

They then tell Sarah their numbers (secretly again). Sarah writes the sum $x+y$ on one paper and the product $xy$ on another. She then shows them one paper randomly. The value on the paper was $2002$. They know this is either the sum or the product, but they don't know which one!

After this, the following conversation take place:

Sam: I don't know your number.

Peter: I don't know your number either.

Sam: Now I know your number.

Peter: Now I know yours too.

How do I figure out what the two numbers are?

  • 3
    $\begingroup$ At first I thought this was a duplicate of puzzling.stackexchange.com/questions/251/…, but on closer inspection, it's a completely different puzzle. $\endgroup$
    – user88
    Commented Apr 16, 2015 at 1:41
  • $\begingroup$ Given how difficult the problem is, I could see Sam and/or Peter being incorrect in their statements. $\endgroup$
    – Jiminion
    Commented Apr 16, 2015 at 13:04
  • $\begingroup$ @Jiminion If each of the four statements could be either correct or incorrect, then those statements don't help us find their numbers, so the numbers could be anything. $\endgroup$
    – kasperd
    Commented Apr 16, 2015 at 13:11
  • $\begingroup$ I was just commenting on how practical reality might impact on a theoretical discussion as stated in this puzzle. :) $\endgroup$
    – Jiminion
    Commented Apr 16, 2015 at 14:55
  • 1
    $\begingroup$ it looks like random puzzle looking at answers below $\endgroup$
    – Abr001am
    Commented Apr 16, 2015 at 18:03

6 Answers 6


Edit: Assuming $y$ is a positive integer, the below reasoning works. Without this assumption, it does not. See ricksmt's answer for the final word on this issue.

Sam: I don't know your number.

Now Peter knows that $x$ is a factor of $2002$: if $x$ didn't divide $2002$, Sam would know that $2002$ wasn't $xy$, so he would know $y=2002-x$.

Peter: I don't know your number.

The same reasoning tells Sam that $y$ is a divisor of $2002$. It also tells him that $2002-y$ is a divisor as well: if it wasn't, then Peter would reason that $2002-y$ couldn't be Sam's number $x$ (since Peter knew Sam's number was a divisor), so that $2002$ couldn't be $x+y$, so he would know $x=2002/y$. The only $y$ for which both $y$ and $(2002-y)$ divide $2002$ is $y=1001$.

Sam: I know your number.

He knows it is 1001.

Peter: Now I know your number.

Peter is lying/mistaken. Both $(x,y)=(2,1001)$ and $(x,y)=(1001,1001)$ are consistent with the first three statements. Basically, Peter had enough info to deduce that Sam knew $y$ even before Sam said his second sentence, so Sam saying "I know $y$" told Peter nothing.

Thus, we can conclude that either Sam, Peter, or your friend are irrational or sinister.

  • $\begingroup$ I think you are right. The only way the the first 2 comments can occur is if $y=1001$. And indeed, this does not help Peter that Sam worked this out... Sam could still have either $2$ or $1001$ and there does not seem to be anything that disambiguates it... $\endgroup$
    – d'alar'cop
    Commented Apr 16, 2015 at 2:52
  • $\begingroup$ But if $x=1001$ then peter in the end will not know be able to decide whether $x=2$ or $x=1001$ and hence the above conversation will not take place , but if $x=2$ Peter will know that $x=2$ $\endgroup$
    – user11489
    Commented Apr 16, 2015 at 15:59
  • $\begingroup$ @user11489 "if $x = 2$ Peter will know that $x = 2$" -- how does $x = 2$ look any different to Peter than $x = 1001$? They're both consistent with Sarah's number and the first three statements. $\endgroup$ Commented Apr 16, 2015 at 16:47
  • $\begingroup$ also don't forget 2000 + 2 is also 2002, so if peter has x = 2 sam's number can be 1001 or 2000. so sam therefore stil doesn't know if it's a devisor so none of them knows right? $\endgroup$
    – Vincent
    Commented Apr 17, 2015 at 13:45

Given Sam's number is $x$ and Peter's number is $y$, most people seem to be working from the following premises:

  • $x, y \in \mathbb{N}$ where $\mathbb{N}$ is the natural integers; $\mathbb{N} = \{1, 2, ...\}$
  • $2002 = x + y \lor 2002 = xy$

If that's correct then you must agree with Mike Earnest's answer or be logically impaired. A stricter reading of the problem provides these premises:

  • $x \in \mathbb{N} = \{1, 2, ...\}$
  • $y \in \mathbb{R}$ where $\mathbb{R}$ is the set of all real numbers
  • $2002 = x + y \lor 2002 = xy$

We can intuitively (and logically) exclude more interesting numbers (complex, imaginary, etc.) for the value of $y$. I've omitted that here.

Sam: I don't know your number.

Of course Sam would have no idea. $\forall n \in \mathbb{N}$ $\exists r_a, r_m \in \mathbb{R}$ such that $(r_a \neq r_m)$ $\land$ $(2002 = x + r_a)$ $\land$ $(2002 = xr_m)$. Thanks, Sam, you told us nothing.

Peter: I don't know your number either.

This is telling. This means that $\exists$ $n_a, n_m \in \mathbb{N}$ such that $(n_a \neq n_m)$ $\land$ $(2002 = n_a + y)$ $\land$ $(2002 = n_my)$ which implies:

$$y \in \mathbb{Z} \;where\; \mathbb{Z} = \{..., -2, -1, 0, 1, 2, ...\}$$

Because $\nexists$ $r \in \mathbb{R}, n \in \mathbb{N}$ such that $2002 = n + r$ $\land$ $r \notin \mathbb{Z}$. Which means if $y \notin \mathbb{Z}$, then Peter could find $x = {2002}/y$. But Peter doesn't know $x$, so $y \in \mathbb{Z}$.

Furthermore, we can deduce:

$$y \in \mathbb{N}$$

$\nexists$ $y \in \mathbb{Z}$ such that $y < 1$ $\land$ $2002 = xy$. If $y < 1$, then Peter could find $x = 2002 - y$.

And finally:

$$ y \in F_y = \{1, 2, 7, 11, 14, 22, 77, 91, 143, 154, 182, 286, 1001\} \subset F$$

Where $F$ is the factors of $2002$. (Note: $F = F_y \cup \{2002\}$.) We know this because $\exists n_a, n_m \in \mathbb{N}$ such that $(n_a \neq n_m)$ $\land$ $(2002 = n_a + y)$ $\land$ $(2002 = n_my)$; otherwise, Peter could eliminate one of the formulas and calculate $x$. The only numbers that satisfy this criteria are in $F_y$.

Sam: Now I know your number.

The big takeaway from this is $x \neq 1001$; $x = 1001$ is the case where Sam still doesn't know $y$. This is because $2002 = 1001 + 1001$ and $2002 = 1001 * 2$. Hence, $y$ could either be $1001$ or $2$, and Sam would not know which number.

Peter: Now I know yours too.

That one bit of info (other inferences aside), must have given Peter enough knowledge to solve the problem, so $x = 1001$ must have been a potential possibility prior to Sam's statement. There's only two values of $y$ for which this is the case:

$$2002 = 1001 + 1001,\;y = 1001$$ $$2002 = 1001 * 2,\;y = 2$$

Which means the other formula will give us the potential values for $x$:

$$2002 = 2 * 1001,\;x = 2$$ $$2002 = 2000 + 2,\;x = 2000$$

So there are two solutions: either Sam picked $2$ and Peter picked $1001$, or Sam picked $2000$ and Peter picked $2$.

Unlike the other version where $y \in \mathbb{N}$, in this case we do not know if $x \in F$. If $x \in F$ then there would only be one solution: Sam picked $2$ and Peter picked $1001$.

  • $\begingroup$ This is fantastic reasoning! In fact, if you look at the question's edit history, the OP initially phrased this as "can you find the numbers?", which would make this problem well formulated with an answer of "no." Looking at the phrasing, and this more pleasing outcome, it does become clear that $y\in\mathbb{R}$ is the more natural interpretation. $\endgroup$ Commented Apr 17, 2015 at 4:57
  • 1
    $\begingroup$ @MikeEarnest Thanks Mike! I didn't think to check to see if the question had been altered, and you gave me an example of \mathbb--I couldn't find how to get that notation, and it made me a little sad. And I think it's funny how the top three answers all reference other answers. It seems to me the question might be intentionally worded so that people go down the $y \in \mathbb{N}$ path; it might be a college problem designed to show students the importance of terminology. $\endgroup$
    – ricksmt
    Commented Apr 17, 2015 at 13:26

Correct, but due to insight from another answerer. Please give primary credit to MikeEarnest

First guy is $\alpha$, his number is $x$. Second guy is $\beta$, his number is $y$. Call the factor set of $2002$, $f = \{2,7,11,13,14,22,26,77,91,143,154,182,286,1001\}$

After the first comment from $\alpha$, $\beta$ can deduce that $x \in f$. This is because $\alpha$, having seen the result on the paper ($2002$), these numbers present ambiguity for sum and product.

$\beta$ now inspects his own number, $y$, and if $y \not\in f$ then he would be able to deduce that $2002 = x + y$ and hence deduce both $x$ and $y$. In this case he would know $x$. But he said he did not know, thus this is impossible.

The other possibility for $\beta$ was that $y \in f$ - he would know that $x * y = 2002$ iff $y \not= 1001$ (because $1001$ still presents ambiguity for sum and product for $x,y \in f$). So the only case where he would not know the answer is if $y=1001$ - and he said he did not know.

Now that $\alpha$ knows that $y=1001$. And he declares this deduction.

Unfortunately, $\beta$ knowing that $\alpha$ knows $y$ does not help him deduce $x$. The first 3 comments could have taken place with either $x=2 \land y=1001$ or $x=1001 \land y=1001$. Thus the forth comment should also have been "I still don't know your number".

  • $\begingroup$ In your fourth paragraph, in parnatheses, how does $2$ present ambiguity? If $y$ was 2, then $x=2000$ would be impossible since this is not a factor, so Peter would know $x=1001$. $\endgroup$ Commented Apr 16, 2015 at 2:37
  • $\begingroup$ @MikeEarnest Yes seems you were right. Well done. I may need to delete and revise actually... $\endgroup$
    – d'alar'cop
    Commented Apr 16, 2015 at 2:40
  • $\begingroup$ yes, because Sam didn't need to use his number to deduce that $y=1001$, so $x=2$ and $x=1001$ should still both be possible in Peter's mind after Sam's second statement. $\endgroup$ Commented Apr 16, 2015 at 2:46
  • $\begingroup$ Yea, Sam has to have chosen 2 and Paul has to have chosen 1001. If it was 1001 and 1001, Paul could work that out on his first statement $\endgroup$ Commented Apr 16, 2015 at 5:39
  • $\begingroup$ @AndrewSmith Can you describe how Paul could have worked out $(1001,1001)$ on his first statement? $\endgroup$ Commented Apr 16, 2015 at 6:03

These are the factors of 2002: 2, 7, 11, 13, 14, 22, 26, 77, 91, 143, 154, 182, 286, 1001. 14 numbers.

If Sam's number is not one of those 14, he will know that 2002 is not reached through multiplication and it is thus reached through addition. He will then take 2002 minus his number and find the answer.

  • $\begingroup$ also, does y have to be a positive integer. You didn't explicitly say it did. $\endgroup$ Commented Apr 16, 2015 at 2:10
  • $\begingroup$ What you are saying is true, but it doesn't explain the conversation and it doesn't explain how to deduce the values $\endgroup$
    – d'alar'cop
    Commented Apr 16, 2015 at 2:40
  • $\begingroup$ it's not entirely true, if you know your own number to be 2 or 1001 you still don't know whether it was a multiplication or a addition. because if you have 2 she can either have 2000 or 1001. if you have 1001 she can either have 1001 or 2. all the other numbers you would know. and following the conversation you know the numbers involved are 2 and 1001 since he does not know. Like @d'alar'cop says, explain the converstation $\endgroup$
    – Vincent
    Commented Apr 17, 2015 at 13:40

Solution: $x=2, y=1001$.

In the beginning we know two things:

  • $x, y\in [1, 2002]$

  • $x+y=2002 \lor x*y=2002$

Every statement of Sam and Peter gives us one more bit of information:

Sam: I don't know your number.

$\Rightarrow x$ has to be a divisor of $2002$, otherwise we could decide $x+y=2002 \lor x*y=2002$ and Sam could calculate $y=2002-x$.

So $x\in M=\{1, 2, 7, 11, 14, 22, 77, 91, 143, 154, 182, 286, 1001, 2002\}$

Peter: I don't know your number either.

$\Rightarrow$ For the same reason, $y$ must be $\in M$ as well.

Peter does still not know the answer at that point, that means he still cannot decide whether $2002=x+y$ or $2002=x*y$. That only works with with $2*1001=2002$ and $1001+1001=2002$

$\Rightarrow (x, y) = (2, 1001)\lor (x, y)=(1001,1001) \lor (x, y)=(1001, 2)$

Sam: Now I know your number.

For $x=1001$, Sam could not decide between $y=2$ and $y=1001$. If Sam knows the answer now, it must mean that $x=2$ and $y=1001$

Peter: Now I know yours too.

Peter can reason as well as we can, so by now he knows that $x=2$.

If Sam wouldn't know the answer before, Peter would know that $x=1001$ at this point. So after Peter's last statement, Sam would know the value of $y$ in any case.


Let me go line by line.

Sam: I don't know your number. since the number he choose was a factor of 2002 {2,7,11,13,14,22,26,77,91,143,154,182,286,1001}, sam was not clear whether the displayed card is addition or multiplication.

Peter: I don't know your number. So peter now knows why sam could not tell and even he could not tell because his number was in the set {2,1001}. So sam's number might be in between 2 and 1001.

Sam: Now I know your number. If sam's number is 1001, he will not be sure about peter's number. But since he choose 2, he was sure about peter's number i.e 1001.

Peter: Now I know yours too. Since sam is sure about his(peter) number, then sam's number must be 2.

Finally sam choose 2,peter choose 1001.

  • $\begingroup$ As explained in another answer, even an outsider will know after the first two statements that Peter's number is 1001. So of course Sam knows that as well regardless of what Sam's own number is. $\endgroup$
    – kasperd
    Commented Apr 16, 2015 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.