home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_01 / HISPEED1.LZH / DOSDEMO / FIBONACC.PAS < prev    next >
Pascal/Delphi Source File  |  1991-07-02  |  519b  |  24 lines

  1. (* Recursive Fibonacci calculation. 26.06.90 *)
  2. {$R-,S+}
  3.  
  4. program Fibonacci(input, output);
  5.  
  6. function fib(n : LongInt) : LongInt;
  7. begin
  8.   if n <= 1 then fib := n else fib := fib(n-1) + fib(n-2);
  9. end;
  10.  
  11. var
  12.   n : LongInt;
  13.  
  14. begin
  15.   Writeln('Calculate some Fibonacci numbers');
  16.   If RunFromMemory then
  17.     Writeln('You can stop a calculation by pressing both shift keys');
  18.   Writeln;
  19.   repeat
  20.     write('Enter number : ');  read(n);  writeln;
  21.     writeln('Result       = ',fib(n))
  22.   until n = 0
  23. end.
  24.