Dennis07

Fibonacci

Jan 27th, 2021
885
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     function Fib(X: UInt64): UInt64;
  2.     var
  3.       LIndex: Integer;
  4.       LSequence: TArray<UInt64>;
  5.     begin
  6.       LSequence := [0, 1, 1];
  7.       SetLength(LSequence, Succ(X));
  8.       for LIndex := 2 to High(LSequence) do
  9.       begin
  10.         LSequence[LIndex] := LSequence[Pred(LIndex)] + LSequence[Pred(Pred(LIndex))];
  11.       end;
  12.       Result := LSequence[High(LSequence)];
  13.     end));
RAW Paste Data