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

1430 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

What is the outcome of the following code? print(2*[3,4,5])


What is the difference between a cycle "if" and "while"?


Why are negative indexes used?


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


We're here to help

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

© MyTutorWeb Ltd 2013–2025

Terms & Conditions|Privacy Policy
Cookie Preferences