## Solution to: Coconut Chaos

Every sailor leaves ^{4}/_{5}(*n*-1) coconuts of a pile of *n* coconuts.
This results in an awful formula for the complete process
(because every time one coconut must be taken away to make the pile divisible by 5):

*r* = ^{1}/_{5}(^{4}/_{5}(^{4}/_{5}(^{4}/_{5}(^{4}/_{5}(^{4}/_{5}(*p*-1)-1)-1)-1)-1)-1),
where *p* is the number of coconuts in the original pile, and *r* is the number of coconuts each sailor gets at the final division (which must be a whole number).

The trick is to make the number of coconuts in the pile divisible by 5, by adding 4 coconuts.
This is possible because you can take away those 4 coconuts again after taking away one-fifth part of the pile:
normally, ^{4}/_{5}(*n*-1) coconuts are left of a pile of *n* coconuts;
now ^{4}/_{5}(*n*+4) = ^{4}/_{5}(*n*-1)+4 coconuts are left of a pile of *n*+4 coconuts.
In the last step, ^{1}/_{5}(*n*+4) = ^{1}/_{5}(*n*-1)+1 coconuts are left of a pile of *n*+4 coconuts.
In this way, the number of coconuts in the pile stays divisible by 5 during the whole process.
So we are now looking for a *p* for which the following holds:

*r* + 1= ^{1}/_{5}×^{4}/_{5}×^{4}/_{5}×^{4}/_{5}×^{4}/_{5}×^{4}/_{5}×(*p*+4) = (4^{5}/5^{6})×(*p*+4),
where *r* must be a whole number.

The smallest (*p*+4) for which the above holds, is 5^{6}.
So there were *p* = 5^{6}-4 = 15621 coconuts in the original pile.

back to the puzzle