1def fib(num):
2 a = 0
3 b = 1
4 for i in range(num):
5 yield a
6 temp = a
7 a = b
8 b = temp + b
9
10
11for x in fib(100):
12 print(x)
13
14
15def fib2(num): # Creates fib numbers in a list
16 a = 0
17 b = 1
18 result = []
19 for i in range(num):
20 result.append(a)
21 temp = a
22 a = b
23 b = temp + b
24 return result
25
26
27print(fib2(100))
28
1def fib(num):
2 a = 0
3 b = 1
4 for i in range(num):
5 yield a
6 a, b = b, a + b # Adds values together then swaps them
7
8for x in fib(100):
9 print(x)