Interview Question






Comment hidden because of low score. Click to expand.
0
of 0 vote

X=2 & Y=2 or X=0 & Y=0

- CodeMonkey May 21, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

sexy dude!

- nagabhushana.s July 01, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

The question doesn't make sense.. either that it's too ambiguous and missing details..
A might not know the numbers, but when B hears the answere, he should imeediately figure out what the 2 numbers are because he knows his product. So why does he have to answer "no"..and then ask again?? WTF. Did you tell B the numbers and is he in the same room. don't post the question if you are not 100% sure..or just have a note saying that..else you are wasting people's time.

- Anonymous May 21, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Two whole numbers, m and n, have been chosen. Both are unequal to 1 and the sum of them is less than 100. The product, m × n, is given to mathematician X. The sum, m + n, is given to mathematician Y. Then both mathematicians have the following conversation:
X: "I have no idea what your sum is, Y."
Y: "That's no news to me, X. I already knew you didn't know that."
X: "Ahah! Now I know what your sum must be, Y!"
Y: "And now I also know what your product is, X!"

The Question: What are the numbers m and n?

- Anonymous May 22, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

m=4 n=2

- Anonymous May 22, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I am sorry its not m=4 and n=2;
I am correcting my ans its m=3 and n=4

- Anonymous May 22, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The answer is X = 13, Y = 4.
I wouldn't ask this question on the interview. Its stupid.

- Anonymous May 22, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

would you mind to explain your answer?

- buried.shopno May 25, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Let a be equal to m × n and let b be equal to m + n.

From the first remark (X: "I have no idea what your sum is, Y.") follows that a can be factorized in more than one way. If, for example, X would have got the number 21, which is the product of the prime numbers 3 and 7, then he would have known immediately that Y could only have got 3+7=10 as sum.

From the second remark (Y: "That's no news to me, X. I already knew you didn't know that.") follows that b cannot be written as the sum of two prime numbers. This also implies that b is not even, because each even number can be written as the sum of two prime numbers. If, for example, Y would have got the number 10, which is equal to 2+8, 3+7, 4+6, or 5+5, then Y could not have known for sure that X could not find out his sum, because X might have got the number 3×7=21 and immediately have known Y's number.

So only a limited amount of possibilities are left for the number b that Y has got: 11, 17, 23, 27, 29, 35, 37, 41, 47, 51, 53, 57, 59, 65, 67, 71, 77, 79, 83, 87, 89, 93, 95, 97 (for all these numbers holds that if you substract 2 of it, you are left with a non-prime number; all even numbers are out anyway, and all odd numbers which can be written as a prime number plus 2 are out too). There are 659 combinations of m and n with which these numbers can be combined as a sum. All these combinations have corresponding products.

As an example, the cases b=11 and b=17 have been worked out below. For convenience, we assume that m is smaller than n:

b=11
m × n = a
2 9 18
3 8 24
4 7 28
5 6 30

b=17
m × n = a
2 15 30
3 14 42
4 13 52
5 12 60
6 11 66
7 10 70
8 9 72

From the third remark (X: "Ahah! Now I know what your sum must be, Y!") we conclude that the number a that X has got, is apparently found at only one value for b. If, for example, X would have got the number 30, he could not find out whether Y has got the number 11 or 17. As can be seen above, the value a=30 is found both at b=11 and b=17 (both 5×6 and 2×15 are equal to 30).

So, for the cases b=11 and b=17 the value of 30 for a is out. For the case b=17 the following values for a are out too:

* 42 (since 2×21=42 and 2+21=23 appears in the list of possible values for b),
* 60 (since 3×20=60 and 3+20=23 appears in the list of possible values for b),
* 66 (since 2×33=66 and 2+33=35 appears in the list of possible values for b),
* 70 (since 2×35=70 and 2+35=37 appears in the list of possible values for b),
* 72 (since 3×24=72 and 3+24=27 appears in the list of possible values for b).

Of the 659 products for all possible values of b, only the 336 products that are present once remain. For the cases b=11 and b=17 the following possibilities remain:

b=11
m × n = a
2 9 18
3 8 24
4 7 28

b=17
m × n = a
4 13 52

From the fourth remark (Y: "And now I also know what your product is, X!") we conclude that for the number b that Y has got, there is apparently only one value of a possible. If, for example, X would have got the number 24, he could find out that Y has got the number 11, but Y could not find out whether X has got the number 18, 24, or 28. As can be seen above, the value b=17 gives only one possible value for a. This also turns out to be the only value for b for which this holds.

Conclusion: the numbers m and n are 4 and 13.

- Abhi May 27, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

crazy question.
What kind of candidate do they expect???

- Anonymous June 05, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Guys....its either (x,y)=(0,0) or (x,y)=(2,2)...........

CodeMonkey, u r great!

- nagabhushana.s July 01, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

for whole number case , it is (3,4)...great guys...I am enjoying

- nagabhushana.s July 01, 2010 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More