summaryrefslogtreecommitdiff
path: root/fpcsrc/tests/bench/shootout/obsolete/fibo.pp
blob: f05bb86105a816377112b90ba256892bbc117650 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
program fibonacci;

{$mode objfpc}

uses SysUtils;

function fib(const N: cardinal): cardinal;
begin
  if N < 2 then fib := 1 else
    fib := fib(N-2) + fib(N-1);
end;

var
  NUM : integer;
  f   : cardinal;

begin
  if ParamCount = 0 then NUM := 1
    else NUM := StrToInt(ParamStr(1));

  if NUM < 1 then NUM := 1;
  f := fib(NUM);
  WriteLn( IntToStr(f) );
end.