def fib sequence if return for in range next_num sequence sequence seq

1
2
3
4
5
6
7
8
9
def fib(n):
sequence = [1,1]
if n <= 2:
return 1
for i in range(2, n):
next_num = sequence[1] + sequence[0]
sequence[0] = sequence[1]
sequence[1] = next_num
return sequence[1]