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.
clearvars,clc
n=[1,2];
for gen=2:60
n(gen+1)=n(gen)+floor(n(gen)/2);
end
d=[0:60;n];
disp(d')
shows
generation population
0 1
1 2
2 3
3 4
4 6
5 9
6 13
7 19
8 28
9 42
10 63
11 94
12 141
13 211
14 316
15 474
16 711
17 1066
18 1599
19 2398
20 3597
21 5395
22 8092
23 12138
24 18207
25 27310
26 40965
27 61447
28 92170
29 138255
30 207382
31 311073
32 466609
33 699913
34 1049869
35 1574803
36 2362204
37 3543306
38 5314959
39 7972438
40 11958657
41 17937985
42 26906977
43 40360465
44 60540697
45 90811045
46 136216567
47 204324850
48 306487275
49 459730912
50 689596368
51 1034394552
52 1551591828
53 2327387742
54 3491081613
55 5236622419
56 7854933628
57 11782400442
58 17673600663
59 26510400994
60 39765601491
Entering
2 3 4 6 9 13 19 28 42
into the OEIS finds sequence
A061418
which matches as far is it goes (39 7972438).
The only closed-form expression given by OEIS is
ceil(k*(3/2)^n) where k = 1.08151366859...
where k is defined as (2/3) * K(3), and the value of K(3) is given to 10,000 places at
so is not realy, truly closed form, if this has to be computed. Of course you could say the same about any closed-form expression involving pi or e, but K(3) is not as well-known as pi or e.
k = 1.08151366859;
n = 60;
ceil(k*(3/2)^n)
does in fact yield
ans =
39765601491
Edited on February 1, 2024, 9:22 pm
|
Posted by Charlie
on 2024-02-01 13:30:52 |