//(8)函数实现:
// 费氏级数: 有繁殖能力的兔子数
function FeiShiJiShu(N: Integer): DWORD;
var
Fn, Fn1, Fn2: DWORD;
I: Integer;
begin
Fn := 0;
if n <=1 then
Result := Fn
else
begin
Fn2 := 0;
Fn1 := 1;
Log(IntToStr(Fn2));
Log(IntToStr(Fn1));
for I:= 0 to N-3 do
begin
if Fn1 >= (High(Fn1) div 2) then // 防止溢出
Break;
Fn := Fn2 + Fn1;
Log(IntToStr(Fn)); // 只须打印 Fn
Fn2 := Fn1;
Fn1 := Fn
end;
Result := Fn;
end;
end;
{
(9)相关特性: 费氏级数与黄金分割点(fn/fn+1)