Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def F_iter(n):
- #count_iter = count_iter + 1
- if (n == 0):
- return 0
- elif (n == 1):
- return 1
- elif (n >1 ):
- fn = 0
- fn1 = 1
- fn2 = 2
- for i in range(3, n):
- fn = fn1+fn2
- fn1 = fn2
- fn2 = fn
- return fn
- else:
- return -1
- def F(n):
- #counter_recurs = counter_recurs+ 1
- if (n == 0):
- return 0
- elif (n == 1):
- return 1
- elif (n > 1):
- return (F(n-1) + F(n-2))
- else:
- return -1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement