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 numberFibonacci.

  • The function should be called fib and should take as input a single integer value in a variable n. It should return an integer value representing the nthn^{th} Fibonacci number.
  • The function should use a loop instead of recursion.

Create a free account to access the full course.

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