Lesson 8: Fibonacci sequence with for loop and list

posted Dec 3, 2019, 7:56 AM by Attila Lengyel
a = 1
b = 1
c = a + b

print(a,b,c)

a = b
b = c
c = a + b

print(a,b,c)

a = b
b = c
c = a + b

print(a,b,c)

print("I'm the while loop")
i = 0
while i < 10:
a = b
b = c
c = a + b
print(a,b,c)
i = i + 1

print("I'm the for loop")
for x in range(0,10):
a = b
b = c
c = a + b
print(a,b,c)

f = [1,1,2]
for x in range(0,22):
f.append(f[len(f)-1] + f[len(f)-2])
print(f)



Comments