function Fib(n: integer): integer;
begin
if n < 3 then Result := 1
else
var (a, b) := (1, 1);
for var i := 3 to n do
(a, b) := (a + b, a);
Result := a
end
end;
for var i := 1 to 10 do Fib(i).Print; // контрольный пример
end.
function Fib(n: integer): integer;
begin
if n < 3 then Result := 1
else
begin
var (a, b) := (1, 1);
for var i := 3 to n do
(a, b) := (a + b, a);
Result := a
end
end;
begin
for var i := 1 to 10 do Fib(i).Print; // контрольный пример
end.
1 1 2 3 5 8 13 21 34 55