(Note. If you missed the "Python Primer" lab and you have no Python experience, please come to Jiho's office hours. We can do this together.)
Fibonacci numbers are defined recursively as below:
f(0) = 0, f(1) = 1
f(n) = f(n-1) + f(n-2)
Implement a fibonacci function fib(n)
, and use it to print out the Fibonacci numbers where n
ranges from 0 to 9 such as:
fib(0) = 0
fib(1) = 1
fib(2) = 1
fib(3) = 2
...
fib(9) = 34
We are going to write a code in Python using Colab notebook. If you are not logged in, use your Google account to log in. Create a new Python 3 notebook (Click the 'NEW PYTHON 3 NOTEBOOK' button on the modal window.)
Write the function which takes a positive integer and returns the Fibonacci number of n. Print the lines using a for loop which iterates over integers from 0 to 9.
After you are done, share your notebook with me ( [email protected]
). That is, click the share button on top-right section, write Jiho's email address in the textbox, and click 'done'. Please write your name in the notebook using + Text
cell.