Advertisement
Guest User

FIBONACCI

a guest
Nov 25th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scilab 0.35 KB | None | 0 0
  1. FIBONACCI:
  2.  
  3. function f = fib(n)
  4.    
  5.     if(n==0) then
  6.         f=0
  7.         return
  8.     else if (n==1)then
  9.             f=1
  10.             return
  11.         end
  12.     end
  13.      f=fib(n-1)+fib(n-2)
  14. endfunction
  15.  
  16. function displayFibonacci ()
  17.     n=input("Podaj ilosc liczb ciagu Fibonacciego: ")
  18.     for i=0:n-1
  19.         disp(fib(i))
  20.     end
  21. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement