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

1810 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

How do you write code to implement a recursive fibonacci algorithm?


Demonstrate a recursive solution to calculate the factorial of a number


Manually implement a function that finds the smallest value in a list of integers and print it.


What are recursive functions and when should they be used?


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