Answer to the Problem of the Week
for the week of May 16, 2005

The Monkey and the Coconuts

The short story titled Coconuts, by Ben Ames Williams, appeared in the Saturday Evening Post on October 9, 1926.
The story tells about five men and a monkey who were shipwrecked on an island.
They spent the first night gathering coconuts.
During the night, one man woke up and decided to take his share of the coconuts.
He divided them into five piles.
One coconut was left over so he gave it to the monkey,
then hid his share and went back to sleep.

Soon a second man woke up and did the same thing.
After dividing the coconuts into five piles,
one coconut was left over which he gave to the monkey.
He then hid his share and went back to bed.

The third, fourth, and fifth man followed exactly the same procedure.
The next morning, after they all woke up,
they divided the remaining coconuts into five equal shares.
This time no coconuts were left over.

What is the smallest number of coconuts there could have been in the original pile?

 


Solution to the Problem:

The original pile had 3121 coconuts.
Martin Gardner said that the Monkey and the Coconuts is "probably the most worked on and least often solved" algebraic puzzle. According to the OMNI magazine (April 1991), this puzzle caused quite a commotion when it appeared in the October 9, 1926 Saturday Evening Post as part of a short story, "Coconuts", by Ben Ames Williams. Williams ended his story without solving the puzzle. It is said that some 2000 letters came to the Saturday Evening Post offices the week after the "Coconuts" appeared, all requesting the puzzle solution.

The smallest number of coconuts there could have been in the original pile is 3121.

        Time  Starting Pile =  Monkey + Share +   New Pile
        ----  -------------    ------   -----     --------
          1      3121       =       1 +   624 +       2496
          2      2496       =       1 +   499 +       1996
          3      1996       =       1 +   399 +       1596
          4      1596       =       1 +   319 +       1276
          5      1276       =       1 +   255 +       1020
          6      1020       =       0 +   204 +        816

 The 3,121 coconuts would be divided as follows:
 the monkey would get       5 coconuts
 the first man would get  828 coconuts
 the second man would get 703 coconuts
 the third man would get  603 coconuts
 the fourth man would get 523 coconuts
 the fifth man would get  459 coconuts

To try to see where this comes from, write down the equations that describe the problem.
We might want to use the letters A through G to represent the sizes of the pile of coconuts,
with A the beginning size, B through F the sizes after each sailor takes a share.
To preserve the pattern, we will let G be the number of coconuts left in the final pile after the monkey and the last sailor have taken theirs.

In that case, the following relationships hold:
        B = A - 1 - ( A - 1 ) / 5 = (4/5) * ( A - 1 )
        C = B - 1 - ( B - 1 ) / 5 = (4/5) * ( B - 1 )
        D = C - 1 - ( C - 1 ) / 5 = (4/5) * ( C - 1 )
        E = D - 1 - ( D - 1 ) / 5 = (4/5) * ( D - 1 )
        F = E - 1 - ( E - 1 ) / 5 = (4/5) * ( E - 1 )
        G = F - 0 - ( F - 0 ) / 5 = (4/5) * ( F - 0 )
Using some algebra (and this is not pretty!), substitute back through the equations. You would obtain:
4096 * A - 15625 * G = 33616
Now, the smallest integer values that make this equation true are: A = 3,121 and G = 816.


Andrea Eberhard sent in the following computer program to solve the problem:
set talk on
f=1
do while f <= 1000
   g=(4*f)/5
   if int(g)=g
      * continue
      e=(5*f+1)/4
      if int(e)=e
         * continue
         d=(5*e+1)/4
         if int(d)=d
            * continue
            c=(5*d+1)/4
            if int(c)=c
               * continue
               b=(5*c+1)/4
               if int(b)=b
                  * continue
                  a=5*b+1
                  if int(a)=a
                      display memory
                      wait      
                  endif
               endif
            endif
         endif
      endif
   endif
   f=f+1
enddo


Sharina Broughton sent in the following computer program to solve the problem:

Solved using following ABAP code:

data total type i value 0.
data formonkey type i.
data count type i value 0.
data newtotal type i.
data subtotal type i.

do 10000 times.
  newtotal = total.
  do 6 times.
    count = count + 1.
    formonkey = newtotal mod 5.

    if formonkey = 1 AND count ne 6.
      subtotal = ( newtotal - 1 ) / 5.
      newtotal = newtotal - subtotal - 1.
    elseif formonkey = 0 AND count = 6.
      write: 'total is ', total.
    else.
      exit.
    endif.
    clear formonkey.
    clear subtotal.
  enddo.
  clear count.
  clear newtotal.
  total = total + 1.
enddo.


Correctly solved by:

1. Keith Mealy Cincinnati, Ohio
2. Andrea Eberhard Columbus, Ohio
3. Charles Washington Winchester, Virginia
4. Walt Arrison Philadelphia, Pennsylvania
5. James Alarie University of Michigan -- Flint,
Flint, Michigan
6. David & Judy Dixon Bennettsville, South Carolina
7. Mrs. Frerk's AP Calculus Class;
    Green Bay East H.S.
Green Bay, Wisconsin
8. John Funk Ventura, California
9. Sharina Broughton Old Dominion University,
Norfolk, Virginia
10. Warner Kennon ----------
11. Jeffrey Gaither Winchester, Virginia