No one breaks any coconuts, so all the variables are integers.
Initial pile: X
First man takes: (X - 1)/5 First man leaves: (X - 1)4/5 = A
Second man gets: (A - 1)/5 Second man leaves: (A - 1)4/5 = B
Third man gets: (B - 1)/5 Third man leaves: (B - 1)4/5 = C
Fourth man gets: (C - 1)/5 Fourth man leaves: (C - 1)4/5 = D
Fifth man gets: (D - 1)/5 Fifth man leaves: (D - 1)4/5 = E
Each man gets: E/5 = F
Substituting:
5F = E = (D - 1)4/5 25F = 4D - 4 25F + 4 = 4D
25F + 4 = 4(C - 1)4/5 125F + 20 = 16C - 16 125F + 36 = 16C
125F + 36 = 16(B - 1)4/5 625F + 180 = 64B - 64 625F + 244 = 64B
625F + 244 = 64(A - 1)4/5 3125F + 1220 = 256A - 256
3125F + 1476 = 256A
3125F + 1476 = 256(X - 1)4/5 15625F + 7380 = 1024X + 1024
15625F + 8404 = 1024X
1024X = 15625F + 8404 "That leaves us two unknowns in one equation."
8404 and 1024X are both divisible by two (twice), so 15625F must be
also, but 15625 is not, so F must be. Say F = 4G.
1024X = 15625(4G) + 8404
256X = 15625G + 2101
2101 is odd, and 256X is even, so 15625G must be odd, so G must be
odd. Say G = 2H + 1 (where H >= 0).
256X = 15625(2H + 1) + 2101 = 15625(2H) + 15625 + 2101
256X = 15625(2H) + 17726
128X = 15625H + 8863 Similarly, H = 2J + 1.
128X = 15625(2J + 1) + 8863 = 15625(2J) + 15625 + 8863
128X = 15625(2J) + 24488
64X = 15625J + 12244 Here, J = 4K.
64X = 15625(4K) + 12244
16X = 15625K + 3061 Here, K = 2M + 1.
16X = 15625(2M + 1) + 3061 = 15625(2M) + 15625 + 3061
16X = 15625(2M) + 18686
8X = 15625M + 9343 Here, M = 2N + 1.
8X = 15625(2N + 1) + 9343 = 15625(2N) + 15625 + 9343
8X = 15625(2N) + 24968
4X = 15625N + 12484 Here, N = 4P.
4X = 15625(4P) + 12484
X = 15625P + 3121
This formula gives all the solutions. The smallest one is where P is
zero, and X is 3121.