Write a recursive function to return the nth Fibonacci number in Python

def fibonacci(n): if n <= 1: return n else: return fibonacci(n-1) + fibonacci(n-2)

Answered by Finn G. Python tutor

1354 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

How would you write a while loop to print all even numbers from 1-10?


Create a python code to sum the number from 1 to 10.


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


What would you expect to be the output of the following code snippet: `a = [1, 2, 3]; b = a; b[1] = 4; print(a); print(b);`, and why?


We're here to help

contact us iconContact usWhatsapp logoMessage us on Whatsapptelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo
Cookie Preferences