{ 斐波那契數列: 1、2、3、5、8、13、21、34、55、89、144 ... 等於前兩數之和 }
{ 昂納多·斐波那契(Leonardo Fibonacci, 1170-1240, 意大利數學家) }
uses Types;
{參數 2 是要獲取的總數}
procedure fbnc(var A: TInt64DynArray; Count: Integer);
var
i: Integer;
begin
SetLength(A, Count);
A[0] := 1;
A[1] := 2;
for i := 2 to Count do A[i] := A[i-2] + A[i-1];
end;
{測試}
procedure TForm1.Button1Click(Sender: TObject);
var
ns: TInt64DynArray;
n: Int64;
begin
fbnc(ns, 90);
Memo1.Clear;
for n in ns do Memo1.Lines.Add(IntToStr(n));
end;
{查看其黃金分割比}
procedure TForm1.Button2Click(Sender: TObject);
var
ns: TInt64DynArray;
i: Integer;
begin
fbnc(ns, 90);
Memo1.Clear;
for i := 0 to Length(ns) - 1 do
begin
if i = 0 then Continue;
Memo1.Lines.Add(FloatToStr(ns[i] / ns[i-1]));
end;
end;