This is a famous old problem. I shall just state the problem here for you, and will follow up in a day or two with a solution and some of its amusing history. Update: Scroll down for a straightforward solution and a “trick” solution.
There are also, by now, various generalizations and different versions. Here’s a basic version:
Five sailors are shipwrecked on a desert island. They quickly determine that the only other inhabitant of the island is a monkey and that the only food is coconuts. They set about collecting as many coconuts as they can and put them all in a very large pile. By nightfall they are too tired to divide the harvest; so they agree to go to sleep and share the coconuts equally the next morning.
During the night one sailor awakens, suspicious that the others might try to cheat him, and decides to take his portion then and there and not wait until morning. He divides the coconuts into five piles and finds there is one coconut left over, which he gives to the monkey. He hides one of the five piles, then puts the rest of the coconuts back into a pile and returns to sleep. Later a second sailor awakens with the same suspicions and does the same thing: He divides the coconuts into five piles, leaving one extra, which he gives to the monkey. Then he hides what he thinks is his share, puts the remaining coconuts into a pile and goes back to sleep.
One after the other, the rest of the sailors do the same: They each take one fifth of the coconuts in the pile (there is always an extra one, which is given to the monkey) and then return to sleep. When the sailors awaken the next morning they all notice the coconut pile is much smaller than it was the night before, but since each man is as guilty as the others, no one says anything. They divide the coconuts (for the sixth time) and again there is one left for the monkey.
How many coconuts were in the original pile?
If you’re interested, give it a good try, and resist the temptation to scour the internet for the solution.
Update: Here is a solution to the problem and a few comments.
Let $x$ represent the number of coconuts in the original pile, and let $y$ represent the number of coconuts that each sailor takes away in the morning.
Now, consider how many coconuts remain in the pile after the first sailor secretly takes a portion away to hide in the night. He tosses one coconut to the monkey, then takes a fifth of the rest, so the number of coconuts remaining in the pile is
$\dfrac{4}{5} ( x – 1)$
Using the same reasoning, the number of coconuts that remains in the pile after the second sailor secretly removes some coconuts in the night is
$\dfrac{4}{5} \left [ \dfrac{4}{5} ( x – 1) – 1 \right ]$
Repeating the same argument three more times, the number of coconuts left in the pile in the morning, before the final sharing, is
$\dfrac{4}{5} \left [ \dfrac{4}{5} \left ( \dfrac{4}{5} \left \{ \dfrac{4}{5} \left [ \dfrac{4}{5} ( x – 1) – 1 \right ] -1 \right \} – 1 \right ) – 1 \right ]$
In the morning, one coconut gets thrown to the monkey, and the remaining coconuts are shared equally five ways. Thus, each sailor receives (besides the ones taken in the night) an additional $y$ coconuts, where
$y = \dfrac{1}{5} \left \{ \dfrac{4}{5} \left [ \dfrac{4}{5} \left ( \dfrac{4}{5} \left \{ \dfrac{4}{5} \left [ \dfrac{4}{5} ( x – 1) – 1 \right ] -1 \right \} – 1 \right ) – 1 \right ] – 1 \right \}$
So, we end up with one equation for two unknowns, which seems not to be solvable. Or rather, there are an infinite number of solutions, about which it seems that no more can be said. However, we have one additional piece of information that has not been used yet: The values of $x$ and $y$ must be whole numbers. That is, the number of coconuts in the pile, and the number taken at any stage, is assumed to be a whole number.
This is part of the reason that mathematics problems are difficult. There are tacit assumptions that one must identify and then translate into mathematical language.
Equations such as the one under consideration are called Diophantine equations, and were studied in antiquity.
I first learned about this problem from a colleague about 25 years ago, when he gave it to me as a challenge. A few years ago I bought the wonderful Martin Gardner book entitled The Colossal Book of Mathematics, and I was delighted to see this problem was the subject of his very first item. He mentions that the problem was first published as part of a short story in the 9 October 1926 issue of The Saturday Evening Post, written by Ben Ames Williams. The offices of the periodical were inundated by 2000 pieces of mail in the first week alone, prompting the editor to send a famous telegram to the author, which read
For the love of Mike, how many coconuts? Hell popping around here.
Gardner goes on to say that the author continued to receive letters about the problem for more than twenty years!
Gardner boils down the last equation above to
$1,024x = 15,625y + 11,529$
and goes on to say that the equation is far too difficult to solve unless a clever trick is used. But there is a nice way to solve the equation, which I will now show you. Expand the equation to get
$y = \dfrac{4^5}{5^6} x – \dfrac{4^5}{5^6} – \dfrac{4^4}{5^5} – \dfrac{4^3}{5^4} – \dfrac{4^2}{5^3} – \dfrac{4}{5^2} – \dfrac{1}{5}$
$y = \dfrac{4^5}{5^6} x – \dfrac{1}{5} \left [ \left ( \dfrac{4}{5} \right )^5 + \left ( \dfrac{4}{5} \right )^4 + \left ( \dfrac{4}{5} \right )^3 + \left ( \dfrac{4}{5} \right )^2 + \left ( \dfrac{4}{5} \right ) + 1\right ]$
Notice that the quantity in square brackets is a geometric series, and can be expressed in a compact and useful form using the results of a previous post. The result is
$y = \dfrac{4^5}{5^6} x – \dfrac{1}{5} \left [ \dfrac{1 – \left ( \dfrac{4}{5} \right )^6}{1 – \dfrac{4}{5}} \right ]$
A little algebraic manipulation, including clearing the fractions, will be helpful:
$y = \dfrac{4^5}{5^6} x – \left [ 1 – \left ( \dfrac{4}{5} \right )^6 \right ]$
$y = \dfrac{4^5}{5^6} x – 1 + \dfrac{4^6}{5^6}$
$5^6(y + 1) = 4^5 x + 4^6$
$5^6(y + 1) = 4^5(x + 4)$
OK, this looks a lot simpler, but it still may not be clear how to make progress. But remember, $x$ and $y$ must be whole numbers. This means that each side of the previous equation is a whole number. How can the two whole numbers represented by each side of the equation possibly be equal? There are six factors of $5$ on the left side of the equation, but where are they on the right? The only way this will work is that
$(x + 4)$ must be a multiple of $5^6$.
And this solves the problem. There are indeed an infinite number of solutions, but we now know all of them. The smallest solution is
$x = 5^6 – 4$
the next largest is
$x = 2(5^6) – 4$
and so on. For each value of $x$, the corresponding value of $y$ is obtained by solving the equation
$5^6(y + 1) = 4^5(x + 4)$
An alternative “trick” solution
Gardner’s solution involves the following trick. Notice that if it were possible to find one solution, all other solutions would differ from it by a multiple of $5^6$. Then (and this is the genius part), notice that $x = -4$ is a solution. What?? A negative number of coconuts??
I don’t think I would ever have noticed this, but once you have been told it, and with the benefit of our equation
$5^6(y + 1) = 4^5(x + 4)$
it’s clear that $x = -4$ and $y = -1$ makes both sides of the equation $0$. Does this make sense? Sort of: If there are $-4$ coconuts in the original pile, and one is thrown to the monkey, leaving $-5$ in the pile, then when a sailor takes one-fifth of the coconuts (that would be $-1$ coconuts), then $-4$ coconuts remain. Each of the sailors do this in turn, and in the morning the sailors are confronted with a pile of $-4$ coconuts, and after they toss one to the monkey, they can evenly divide the pile by taking $-1$ coconut each.
But in certain problems a standard idea is to look for “fixed-point” solutions. If we were to do this here (that is, imagine a number of initial coconuts such that after the first sailor’s withdraw yields the same number of coconuts in the pile) we would be led to the equation
$x = \dfrac{4}{5}(x – 1)$
the solution of which is
$5x = 4x – 4$
$x = -4$
So does this clever solution require genius or not? I don’t know.
In any case, legend had it that Dirac was the one who thought up this delightful trick, so Gardner wrote to Dirac to inquire whether this was the case. He said that he heard the negative solution from the mathematician J.H.C. Whitehead. Gardner wrote to him as well, but Whitehead said that he had heard the negative solution from someone else, and Gardner gave up the trail at that point.
Check the Gardner book for generalizations and further literature on this problem if you’re interested in digging deeper.
(This post first appeared at my other (now deleted) blog, and was transferred to this blog on 22 January 2021.)