There are actually two variants for the coconuts puzzle. In the older, easier one the monkey gets an extra coconut at the end. Versions of this one apparently go back to the middle ages. The newer version used by William, where the monkey only gets 5 coconuts, is more difficult to solve.

The Diophantine approach is to build up a polynomial as follows (for the older version of the puzzle):
N = 5A + 1
4A = 5B + 1
4B = 5C + 1
4C = 5D + 1
4D = 5E + 1
4E = 5F + 1

N is the original number of coconuts, and F is the number that each of the 5 sailors received at the end. The way to read this is, at the beginning, sailor A divided the pile “N” 5 ways, kept one pile of size “A”, and had 1 coconut left over that he gave to the monkey. Now, there is a pile of 4*A coconuts that is divided 5 ways by sailor B. He keeps one pile of size “B”, has one coconut left over for the monkey, and puts the other four B-sized piles back together again, etc.

If we turn this into one equation by normalizing A, B, C, D and E (i.e. – E = (5F+1)/4; D = (5E+1)/4 = (5F+1)*5/16; etc.) we get 1,024*N = 15,625*F + 11529.

We want the smallest positive value of N such that both N and F are integers. This is easy to do in VBScript as a simple program to run N from 1 to 10,000, but not so easy to derive by hand. (My solution is N = 15,621, F = 1,023.)

One of the interesting things about the Diophantine equations is that some of them have only one solution, others have infinite solutions, and others have none. In our case, the coconut problem has an infinite number of solutions, so we want the smallest one.

However, Gardner presents a twist approach using negative coconuts, which dates back to Norman Manning in 1912. Alternatively, you could take some of the coconuts and paint them blue to be easier to track. The reasoning goes – if you’re dividing up the coconuts into 5 equal piles 6 times, with no leftover coconut for the monkey at the end, then the smallest number that would work is 5^6 = 15625. Now, take four of those 15,625 coconuts, paint them blue and put them in the bushes. This leaves you with 15,621 coconuts, which you CAN divide into 5 piles, with one for the monkey for round 1. Put the four blue coconuts plus the other 4 piles together to make one pile of 5^5 coconuts. This can obviously be divided by 5. But, we pull the 4 blue ones and give the extra to the monkey. In Gardner’s words “This procedure – borrowing the blue coconuts only long enough to see that an even division into fifths can be made, then putting them aside again, is repeated at each division.” After the last round, the blue coconuts are left in the bushes, not belonging to anyone.

The use of blue, or negative, coconuts explains something I discovered when I ran my program. One of the solutions is for N = -4, and F = -1. Adding 5^6 (15,625) to this N gives 15,621, which is the next solution my program found, with f = 1,023. All subsequent solutions have the form N = k*5^6 – 4, and F = k*4^5 – 1 (where k runs from 1 to infinity).

The above description is for the variant of the puzzle where the monkey gets that 6th coconut in the final round of dividing the coconuts into 5 piles. For William’s version, where the last round doesn’t have the extra coconut, the Diophantine equation is:
1,024*N = 15,625*F + 8404

There’s a different general equation that can be used here, depending on whether “n”, the number of sailors, is even or odd:
# Coconuts = (1 + nk)*n^n – (n-1)  : for even n
# Coconuts = (n – 1 + nk)*n^n – (n-1) : for odd n

k is the multiplier used above to get infinite solutions as multiples of N, and for the lowest positive solution, k=0.
For n = 5 sailors,
N = # Coconuts = (1 + 0*5)*5^5 – (5-1)
N = 1*3125 – 4
N = 3,121
The last round of divvying will give 5 piles of 204 coconuts, and nothing extra for the monkey.

Finally, the last puzzle on Monday had three sailors finding the pile of coconuts. The first sailor takes 1/2 of the pile, plus half a coconut. The second sailor takes half of the remaining pile plus half a coconut. The third sailor does the same thing. Left over is exactly one coconut, which they give to the monkey. How many coconuts did they start with?
If you work backwards,
(1 + 1/2) * 2 = 3
(3 + 1/2) * 2 = 7
(7 + 1/2) * 2 = 15

Comments: Man, I never expected this chapter of the book to give me so many problems. I’d initially thought I’d spend an hour writing it up and that’d be the end of it. But, I kept making mistakes in forming the Diophantine equations for each puzzle, and both my math, and my VBScript program kept coming out wrong. I spent close to 2 days on this one.

Obviously, I’m not as good at recreational math puzzles as I’d liked to think I was.

This site uses Akismet to reduce spam. Learn how your comment data is processed.