Skip to content

Instantly share code, notes, and snippets.

@romanegloo
Last active October 24, 2019 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romanegloo/398e67f5980d510752501b7c04e634bb to your computer and use it in GitHub Desktop.
Save romanegloo/398e67f5980d510752501b7c04e634bb to your computer and use it in GitHub Desktop.

(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 ( jiho.noh@uky.edu ). 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment