08-05-2024, 03:28 PM
My friends and I aren't as gluttonous as you and your friends! Here's my solution, which doesn't necessarily work from the premise that they began with a whole number of apples -- I worked from the back end up, assuming that coming morning time, each person had at least full 1 apple and the donkey had 1.
Code: (Select All)
'x = numbers of apples per person
'In the morning there were:
'3x + 1 apples. (Each person got an equal share, the donkey got one.)
'In the night, the third friend ate 1/3 of the apples and gave the donkey one. (There were 2/3 remaining)
'that means before that, there were:
' 1.5 * (3x+ 1) + 1
'Before that, the 2nd friend did the same:
' 1.5 * (1.5 * (3x + 1) + 1) + 1
'Before that, the 1st friend did the same:
' 1.5* (1.5 * (1.5 * (3x + 1) + 1) + 1) +1
PRINT "#1", "#2", "#3,", "Donkey", "Total"
FOR x = 1 TO 10
PRINT 1.5 * (1.5 * (1.5 * (3 * x + 1) + 1) + 1) + 1 ,_
1.5 * (1.5 * (3*x + 1) + 1) + 1 ,_
1.5 * (3*x+ 1) + 1,_
4,_
1.5 * (1.5 * (1.5 * (3 * x + 1) + 1) + 1) + 1 + _
1.5 * (1.5 * (3*x + 1) + 1) + 1 + _
1.5 * (3*x+ 1) + 1 +_
4
NEXT
Quote:#1 #2 #3, Donkey Total
18.25 11.5 7 4 40.75
28.375 18.25 11.5 4 62.125
38.5 25 16 4 83.5
48.625 31.75 20.5 4 104.875
58.75 38.5 25 4 126.25
68.875 45.25 29.5 4 147.625
79 52 34 4 169
89.125 58.75 38.5 4 190.375
99.25 65.5 43 4 211.75
109.375 72.25 47.5 4 233.125