Implement a fibonacci function which calculates the nth number of the fibonacci sequence.

def fib(n):  if n <= 1:    return n  else:    return(fib(n-1) + fib(n-2))
This is the code for a very basic version. This coud be used to explain how recursion works thanks to a relatively easy example.

AF

Related Python Mentoring answers

All answers ▸

Give an example of a FOR loop


Write a basic program to output the lowest of 3 input numbers. (You may omit error checks on your inputs)


With the help of Pandas and Numpy library create a DataFrame with the columns "Name", "Surname", "Age" and "Gender", create as many rows as you want. Print out the result.


Write a python function that takes a string as parameter and returns the character in the string with the most occurrences, along with the number of times this character occurs