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)

FG
Answered by Finn G. Python tutor

1794 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Explain how python programs are structured and give an example of how methods are initiated


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


Use recursion to print all the sublists of a given list


How would you get a piece of code to print the numbers 1 to 10


We're here to help

contact us iconContact ustelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

MyTutor is part of the IXL family of brands:

© 2026 by IXL Learning