Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. def recurssive_fib(input):
  2.     if input is 0:
  3.         return 0
  4.     elif input is 1:
  5.         return 1
  6.     else:
  7.         return recurssive_fib(input-1) + recurssive_fib(input-2)
  8.  
  9. def fib(input):
  10.     if input is 0:
  11.         return 0
  12.     elif input is 1:
  13.         return 1
  14.     else:
  15.         fiblist = [0,1]
  16.         for i in range (2, input+1):
  17.             fiblist.append(fiblist[i-2] + fiblist[i-1])
  18.         return fiblist[-1]
  19.  
  20.  
  21.  
  22. #print(recurssive_fib(25))
  23. print(fib(40))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement