It's like Fibonacci but starting with only one male rabbit, and adding a female in the second month. Rabbits are immortal, and male/female pairs produce one offspring every month. Numbers of males and females are kept equal as far as possible - that is, two pairs of rabbits will produce a male/female pair, and a single pair of rabbits will produce a male, unless an odd male already exists from an earlier month, in which case they will produce a female.
Produce a closed form expression for the number of rabbits after the nth month, and use this to compute the total number of rabbits after 5 years.
(In reply to
Possible issue by broll)
clearvars,clc
n=[1,2]; added=[1,1];
for gen=2:60
added(gen+1)= floor(n(gen)/2);
n(gen+1)=n(gen)+floor(n(gen)/2);
end
d=[0:60;n];
disp(d')
d=[0:60;added];
disp(d')
adds the following table of additions in each month:
0 1
1 1
2 1
3 1
4 2
5 3
6 4
7 6
8 9
9 14
10 21
11 31
12 47
13 70
14 105
15 158
16 237
17 355
18 533
19 799
20 1199
21 1798
22 2697
23 4046
24 6069
25 9103
26 13655
27 20482
28 30723
29 46085
30 69127
31 103691
32 155536
33 233304
34 349956
35 524934
36 787401
37 1181102
38 1771653
39 2657479
40 3986219
41 5979328
42 8968992
43 13453488
44 20180232
45 30270348
46 45405522
47 68108283
48 102162425
49 153243637
50 229865456
51 344798184
52 517197276
53 775795914
54 1163693871
55 1745540806
56 2618311209
57 3927466814
58 5891200221
59 8836800331
60 13255200497
Entering
1 1 2 3 4 6 9 14 21 31 47 70 105
into OEIS gives
A073941 and A005428, which seem to be the same except for an offset.
The given closed formula is
a(n) = ceiling(c*(3/2)^n-1/2) where c = 0.3605045561966149591015446628665... - Benoit Cloitre, Nov 22 2002
and it checks out as not needing an offset with
>> c=0.360504556196614
c =
0.360504556196614
>> n=60
n =
60
>> ceil(c*(3/2)^n-1/2)
ans =
13255200497
|
Posted by Charlie
on 2024-02-02 11:31:53 |