Sunday, January 23, 2005

The Monkey and the Coconuts

Here's another nice question.....
Five men and a monkey were shipwrecked on a desert island, and they spent the first day gathering coconuts for food. Piled them up all together and then went off to sleep for the night.
But when they were all asleep one man woke up, and he thought there might be a row about dividing the coconuts in the morning, so he decided to take his share. So he divided the coconuts into five piles. He had one coconut left over, and he gave that to the monkey. He hid his piles and put all the rest back together.
By and by the next man woke up and did the same thing. And had one coconut left over and gave it to the monkey. And in the morning they divided what coconuts were left and they came out in five equal shares. Of course each one must have known there were coconuts missing; but each one was guilty as the others , so they didn't say anything. How many cocnuts were there in the beginning....?????
This problem is a very famous one. And I suggest that you think it over nicely before looking up the answer.

3 Comments:

Blogger Prateek said...

Well the answer is 3121. I just wrote a C++ program and got this answer, I've rechecked it anyways.

11:06 PM  
Blogger Swati Gupta said...

Good...Now can you generalise for "n" people and 1 monkey???
(That might need some maths and logic !!)

11:17 PM  
Blogger Swati Gupta said...

Ok.. Enough time for everyone to think about it...
The ans is
" When n, the number of men is odd then the no. of coconuts is : (1+nk)n^n-(n-1)
When n is even, then no. of coconuts is: (n-1+nk)n^n-(n-1)"
In both equations k is a parameter that can be any integer. To get the lowest possible solution, put k=0.

Now, think about another modification in which the monkey is given a coconut in the end also. How many coconuts would be there in that case?

5:54 PM  

Post a Comment

<< Home