RosettaCodeData/Task/Fibonacci-sequence/Pascal/fibonacci-sequence-6.pas

19 lines
469 B
ObjectPascal
Raw Permalink Normal View History

2026-02-01 16:33:20 -08:00
function Fibo_BigInt(n: integer): string; //maXbox
var tbig1, tbig2, tbig3: TInteger;
begin
result:= '0'
tbig1:= TInteger.create(1); //temp
tbig2:= TInteger.create(0); //result (a)
tbig3:= Tinteger.create(1); //b
for it:= 1 to n do begin
2026-04-30 12:34:36 -04:00
tbig1.assign(tbig2)
tbig2.assign(tbig3);
tbig1.add(tbig3);
tbig3.assign(tbig1);
end;
2026-02-01 16:33:20 -08:00
result:= tbig2.toString(false)
tbig3.free;
tbig2.free;
tbig1.free;
end;