fibo.pp 365 B

123456789101112131415161718192021222324
  1. program fibonacci;
  2. {$mode objfpc}
  3. uses SysUtils;
  4. function fib(const N: cardinal): cardinal;
  5. begin
  6. if N < 2 then fib := 1 else
  7. fib := fib(N-2) + fib(N-1);
  8. end;
  9. var
  10. NUM : integer;
  11. f : cardinal;
  12. begin
  13. if ParamCount = 0 then NUM := 1
  14. else NUM := StrToInt(ParamStr(1));
  15. if NUM < 1 then NUM := 1;
  16. f := fib(NUM);
  17. WriteLn( IntToStr(f) );
  18. end.