Guest User

Untitled

a guest
Apr 24th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.21 KB | None | 0 0
  1. def fib_iterative(n):
  2. if n <= 1:
  3. return n
  4.  
  5. fib_sequence = [0, 1]
  6.  
  7. while(len(fib_sequence) <= n):
  8. fib_sequence.append(fib_sequence[-1] + fib_sequence[-2])
  9.  
  10. return fib_sequence[-1]
Add Comment
Please, Sign In to add comment