The Monkey and the Coconuts
— Solution


Firstly, let’s look at the solution for the original puzzle where a coconut is left over after the final division in the morning so the monkey ends up with 6 coconuts.


Basic algebra gives you this equation: N = {(15625 × F)+ 11529} / 1024 where N is the number of coconuts they collected originally and A to F are the number of coconuts taking from the pile at each division with F being the number each sailor got in the final division in the morning. What we want is a value of F such that {(115625 × F) + 11529} is a multiple of 1024 so that N is a whole number. But if {(115625 × F) + 11529} is a multiple of 1024, then we can subtract 1024 from both of the two numbers as many times as we like and still get something which is a multiple of 1024. Doing this as far as we can leaves {(265 × F) + 265}. This can be written as 265 × (F+1). Now for this to be a multiple of 1024, since 265 is fixed, (F+1) must be a multiple of 1024. And the smallest such value could be is F = 1023. This gives a solution of N = [(15625×1023)+11529)]/1024 which works out as 15,621 coconuts.


Still looking for this.


If you can imagine -4 coconuts in the original pile, and +1 is thrown to the monkey, this would leave -5 in the pile, so when a sailor takes one-fifth of the coconuts (that would be -1 coconut), 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. After they toss +1 to the monkey, they can evenly divide the pile by taking -1 coconut each. The smallest whole number of divisions needs 56, that is 5×5×5×5×5×5 = 15,625. Adding this to -4, which is one solution, this gives the smallest positive solution of 15,621 coconuts.

Postscript. This table shows the process:

given to


Secondly, let’s look at the solution for the William’s puzzle rediscovered by Martin Gardner. Here the final division in the morning does not leave a coconut left over for the monkey so it ends up with only 5 coconuts.


Using basic algebra as before gives you an equation: N = {(15625 × F)+ 8404} / 1024 where F is the number each sailor got in the final morning share-out and N is the number of coconuts to begin with. However there is a simpler method if you follow the logic slowly.

As before we use N as the initial number (a whole number) but then we work out the number left after each sailor has reduced the pile. Note that it doesn’t matter if we deduct the monkey’s coconut before of after taking away the fifth share each time.

After the first sailor’s action the number of coconuts left N1 => [4(N-1)/5]. We can expand this to 4N/5 -4/5. Using a sleight of hand we add +16/5 and -16/5 to the equation (which makes no difference as the two figures cancel each other out) allowing us to say that N1 => (4N+16)/5 - 20/5 and finally giving N1 => [4(N+4)]/5 - 4.

Now after the second sailor takes his share and gives one to the monkey,
    N2 => [4(N1+4)]/5 - 4
working on the right hand side of the equation
    N2 => [4 × {([4(N+4)]/5 - 4+4)}/5] - 4
    N2 => [4 × {([4/5 ×(N+4)] - 4+4)}]/5 - 4
    N2 => [4 × {([4/5 ×(N+4)])}]/5 - 4
    N2 => [42 × (N+4)]/52 - 4
    N2 => [16 × (N+4)]/25 - 4

With all five sailors taking their fifths and giving the monkey a coconut, the reducing pile works out like this:

after division by sailor 1, number of coconuts left N1 =>     [4 × (N+4)]/5 - 4
after division by sailor 2, number of coconuts left N2 =>    [16 × (N+4)]/25 - 4
after division by sailor 3, number of coconuts left N3 =>    [64 × (N+4)]/125 - 4
after division by sailor 4, number of coconuts left N4 =>  [256 × (N+4)]/625 - 4
after division by sailor 5, number of coconuts left N5 => [1024 × (N+4)]/3125 - 4

Since the final amount must be a whole number, (N+4) must equal 3125 or a multiple of it. However for the smallest answer it must equal 3125, so that N+4 = 3125 and therefore the original pile N = 3,121 coconuts. The final pile of coconuts left in the morning is [({1024 × (3121+4)}]/3125 - 4 which equals 1020 and divides exactly by 5 with none for the monkey.


Look at a simpler example. With three sailors, guessing that the number of coconuts will be 3x3x3x3 = 81. However when the first sailor divides the pile by 3 there is none left over so the original pile needs to be 82. Howver when the second sailor divides the reduced pile of 54 by 3 there is again none left over so we need to add another coconut for the monkey. This makes the original pile 83 which cannot be right as it leaves 2 spare after the first division. Since adding does not work how about subtracting? You need to take 2 away and make the beginning pile 79 if you are to get the first division to have a remainder of 1 but this works right through. Now two is the number of sailors minus 1.

So for our puzzle the answer must be 55, that is 5×5×5×5×5, minus (5-1) which works out as 3125 - 4 = 3,121 coconuts.


Still looking for this.

Postscript: This table shows the process:

given to

The five sailors ended up in the order of their raiding the hoard with 828, 703, 603, 523 and 459 coconuts.