Exercises on Functions

Test yourself by trying to solve the challenging questions provided in this lesson!

We'll cover the following

Question 1

Write a function that computes the nthn^{th} Fibonacci number. Your function should be called fib and should take as input a single integer value n, and should return an integer value representing the nthn^{th} Fibonacci number.

Write your own function that doesn’t use recursion, but uses a loop instead.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy