In a certain tribe, you have a certain amount of tribal offerings, at the start of year 1. However, at the start of each year (including this one), you must feed the black hole with a number of tribal offerings equal to the size of the black hole. On year 1, the black hole starts as size 1 and doubles each year that you pay the tribal offerings. (If it was 4, it's 8 now.) If you can't pay this cost, the island will explode in the middle of this year.
However, your workers are very industrious with investing, and always manage to double the number of tribal offerings that you had at the beginning of the year after paying the black hole.
For example, if you started with 4 offerings: (B = beginning of year before feeding the black hole, A = after you fed the black hole, E = end of year after your tribal offerings have doubled)
--B-A-E
1|4 3 6
2|6 4 8
3|8 4 8
4|8 0 0
5|0
Since there wasn't enough to pay 16 tribal offerings, the island lasted 5 years.
How would you find the number of turns this island would last if you started with x tribal offerings?
I don't have a proof, but the following program shows it always seems to last one more round than the starting number:
FOR n = 4 TO 40
blh = 1
amt = n
round = 0
DO
round = round + 1
IF amt < blh THEN EXIT DO
amt = amt - blh
amt = amt * 2
blh = blh * 2
LOOP
PRINT n, round
NEXT
giving
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
|
Posted by Charlie
on 2004-02-18 10:48:01 |