Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Five sailors and a monkey were shipwrecked on a deserted island, and they spent the first day gathering coconuts for food, piled them all up together and went to bed. But when they were all asleep one sailor woke up, and he thought that there might be a row about dividing the coconuts in the morning, so he decided to take his share. He divided the coconuts into five piles. He had one coconut leftover, and he gave that to the monkey, and he hid his pile and put the rest back together. By and by the next sailor woke up and did the same thing. And he had one leftover, and he gave it to the monkey. And all five sailors did the same thing one after another. Each taking a fifth of the coconuts in the pile, and each having one leftover for the monkey. In the morning they divided the coconuts that were left and they came out in five equal shares and one coconut leftover and gave that to the monkey. How many coconuts were there in the beginning?

share|cite|improve this question
This question seems to be a duplicate of this. – Rick Decker Jan 25 '13 at 16:06
@Rick. I didn't now for that question that look very similar but isn't the same in last share in my question one coconut go to the monkey. – Adi Dani Jan 25 '13 at 16:13
Ah. I missed that. Sorry. – Rick Decker Jan 25 '13 at 16:16
Nice Adi +111111 – S. Snape Jun 6 '13 at 8:02
up vote 11 down vote accepted

According to MathWorld, the smallest positive solution is $15621$ coconuts. The smallest positive solution if the coconuts divide evenly at the end, with none left over for the monkey, is $3121$. The link gives an outline of the solution to this classic Diophantine problem. A detailed solution can be found in this PDF, alone with the slick shortcut solution:

By inspection $-4$ is a solution: when it’s divided into $5$ piles of $-1$ with $1$ left over for the monkey, and one of the piles is removed, $-4$ coconuts remain for the next division. It’s also not too hard to see that $5^6=15625$ can be added to any solution to obtain another, since the pile is divided into $5$ piles $6$ times; thus, $15621$ is a solution.

share|cite|improve this answer

This solution will satisfy any number of sailors & coconuts:

$n$ is the number of sailors

$c$ is the number of coconuts given to the monkey by each sailor.

Initial number of coconuts = $\left(n^{n+1}\right)-c(n-1)$

Bala Nair

share|cite|improve this answer
Can you explain how you came to this solution. – Adi Dani Dec 6 '13 at 23:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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