For Loops and Recursive Sequences in Python
Author: David Manuel
In this video, we use for loops in Python to generate a recursively defined sequence. In particular, we will generate the first fifty Fibonacci numbers.
Transcript 27
Transcript 27
Exercises
Python Code:
Generate and print the first 50 Fibonacci numbers
a=[1,1]
for n in range(2,50):
a.append(a[n-2]+a[n-1])
print('The first 50 Fibonacci numbers are',a)
Open Python Notebook File
Generate and print the first 50 Fibonacci numbers
a=[1,1]
for n in range(2,50):
a.append(a[n-2]+a[n-1])
print('The first 50 Fibonacci numbers are',a)
Open Python Notebook File
