LAST EDITED ON Aug-10-03 AT 02:51 AM (EST)
Hi Bractals and Nathan,"When posting a problem, make sure to show your work". Please. It is written at the top of this window in red. Since you did not (for this problem), I will. I hope that other visitors will appreciate that.
First, back to the monkey and the coconuts. Apparently, there are 2 versions of the puzzle. In the first version, each guy divides the pile, pockets his share, and gives the remaining 1 coconut to the monkey. In the second version, each guy divides the pile (without any remainder), pockets his share, and after that the monkey steals 1 coconut. In both versions, the monkey gets 1 coconut in the morning. Let Q be the initial pile of coconuts and n the number of coconuts each guy gets in the morning. The pile is depleted like this:
1. version (monkey is given 1 coconut before dividing):
Q
(Q - 1)·4/5
((Q - 1)·4/5 - 1))·4/5
(((Q - 1)·4/5 - 1))·4/5 - 1)·4/5
((((Q - 1)·4/5 - 1))·4/5 - 1)·4/5 -1)·4/5
(((((Q - 1)·4/5 - 1))·4/5 - 1)·4/5 -1)·4/5 - 1)·4/5 = 5n + 1
(5 lines not counting the first)
Q·(4/5)5 - (4/5)5 - (4/5)4 - (4/5)3 - (4/5)2 - 4/5 = Q·(4/5)5 - G = 5n + 1
The sum of the finite geometric sequence G is
G = 4/5·(1 - (4/5)5)/(1 - 4/5) = 4 - 4·(4/5)5
Q·(4/5)5 - 4 + 4·(4/5)5 = 5n + 1
Multiplying the equation by 55 we get
45(Q + 4) = 56(n + 1)
The trivial solution is n = -1 and q = -4 and the smallest positive solution is n = 45 - 1 = 1023, Q = 56 - 4 = 15621.
2. version (monkey steals 1 coconut after dividing):
Q
Q·4/5 - 1
(Q·4/5 - 1)·4/5 - 1
((Q·4/5 - 1)·4/5 - 1)·4/5 - 1
(((Q·4/5 - 1)·4/5 - 1)·4/5 -1)·4/5 - 1
((((Q·4/5 - 1)·4/5 - 1)·4/5 -1)·4/5 - 1)·4/5 - 1 = 5n + 1
(5 lines not counting the first)
Q·(4/5)5 - (4/5)4 - (4/5)3 - (4/5)2 - 4/5 - 1 = Q·(4/5)5 - G = 5n + 1
The sum of the finite geometric sequence G is
G = (1 - (4/5)5)/(1 - 4/5) = 5 - 5·(4/5)5
Q·(4/5)5 - 5 + 5·(4/5)5 = 5n + 1
Multiplying the equation by 55 we get
45(Q + 5) = 55(5n + 5 + 1)
There is no trivial integer solution. The smallest positive solution will be for
5n + 5 + 1 = 45·k
n = (45·k - 1)/5 - 1
where k > 0 is an integer. Since 45 = 1024 and we need the lowest multiple ending by 6, obviously k = 4 and 45·k = 4096.
n = (4096 - 1)/5 - 1 = 818
Q = 55·k - 5 = 3125·4 - 5 = 12495
Personally, I think that the absence of the trivial solutuion with negative coconuts takes away all fun from the 2nd version.
Finally, I am getting to the genie problem: Q pennies to start with, M > 1 men, each drops 0 < N < M pennies back to the urn (the remainder of dividing), and the last division in the morning has no remainder. Let n be the number of pennies each guy gets in the morning. The pile of penies is depleted in the same manner as in the 1st version of the monkey and the coconuts problem - the only difference is that the last line does not equal to Mn + N but to Mn:
Q
(Q - N)·(M-1)/M
((Q - N)·(M-1/M - N))·(M-1)/M
(((Q - N)·(M-1)/M - N))·(M-1)/M - N)·(M-1)/M
...
(...(((Q - N)·(M-1)/M - N))·(M-1)/M - N)·(M-1)/M - ... - N)·(M-1)/M = Mn
(M lines not counting the first)
Q·((M-1)/M)M - N·((M-1)/M)M - N·((M-1)/M)M-1 - ... - N·(M-1)/M = Q·((M-1)/M)M - G = Mn
The sum of the finite geometric sequence G is
G = N·(M-1)/M·(1 - ((M-1)/M)M)/(1 - (M-1)/M) = N(M - 1)(1 - ((M-1)/M)M)
Q·((M-1)/M)M - N(M - 1) + N(M - 1)·((M-1)/M)M = Mn
Multiplying the equation by MM we get
(M - 1)M·(Q + N(M - 1)) = MM·(Mn + N(M - 1))
Trying
Mn + N(M - 1) = 0
n = N - 1/M
we see that n would not be an integer and therefore there is no trivial solution. The smallest positive solution will be for
Mn + N(M - 1) = (M - 1)M·k
where k > 0 is an integer:
n = ((M - 1)M·k - NM + N)/M
We can imagine (M - 1)M·k as a binomial sum in which every member but the last one is divisible by M. If M is even, the last member is +k, and if M is odd, the last member is -k. Since n must be an integer
N + k must be divisible by M if M is even
N - k must be divisible by M if M is odd
As we are looking for the smallest k > 0 possible, we can use
k = M - N if M is even
k = N if M is odd
If M = 2, the only possibility for N is N = 1. For k = M - N = 2 - 1 = 1 we get n = ((2 - 1)2·(2 - 1) - 1·2 + 1)/2 = 0, which is not acceptable. Therefore, for M = 2 we have to use k = M - N + M = 2M - N = 4 - 1 = 3. For M > 2, n is always positive.
In conclusion:
n = ((2 - 1)2·3 - 1·(2 - 1))/2 = 1 if M = 2
n = ((M - 1)M(M - N) - N(M - 1))/M if M > 2 is even
n = ((M - 1)MN - N(M - 1))/M if M > 1 is odd
Since
Q + N(M - 1) = MM·k
Q = 22·3 - 1·(2 - 1) = 11 if M = 2
Q = MM(M - N) - N(M - 1) if M > 2 is even
Q = MMN - N(M - 1) if M > 1 is odd