Advertisement
Semior001

Fibonachchi

Nov 13th, 2016
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.31 KB | None | 0 0
  1. var
  2.     n: integer;
  3.  
  4. function fib(n: integer): integer;
  5. begin
  6.     if n=1 then
  7.         fib:=1
  8.     else if n=2 then
  9.         fib:=1
  10.     else
  11.     begin
  12.         fib:=fib(n-1) + fib(n-2);
  13.     end;
  14. end;
  15.  
  16. begin
  17.     write('Введите число N: ');
  18.     readln(n);
  19.     write('N-ное число Фибоначчи равно: ', fib(n));
  20. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement