Let the original pile have n coconuts. Let a be the number of coconuts in each of the five piles made by the first man, b the number of coconuts in each of the five piles made by the second man, and so on.
Writing a Diophantine equation to represent the actions of each man, we have
| n = 5a + 1 | |
| 4a = 5b + 1 | |
| 4b = 5c + 1 | |
| 4c = 5d + 1 | |
| 4d = 5e + 1 | |
Hence n + 4 = 5 × (5/4)4 (e + 1), and so n = (55/44) (e + 1) − 4.
Note that, since 5 and 4 are relatively prime, 55/44 = 3125/256 is a fraction in its lowest terms. Hence the only integer solutions of the above equation are where e + 1 is a multiple of 44, whereupon d + 1, c + 1, b + 1, and a + 1 are all integers.
So the general solution is n = 3125r − 4, where r is a positive integer, giving a smallest solution of 3121 coconuts in the original pile.
It's clear from the form of the equations that we can generalize this result. Given m > 2 men in the airplane, the smallest solution would be mm − (m−1) coconuts. This follows because, for m > 2, m and m−1 are always relatively prime. (Any divisor of m and m−1 must also divide their difference.)
Source: Ben Ames Williams