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

1511 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

How do you define a class in python


Create an rock, paper, scissors game. The user should input one option, and the computer should play randomly.


What is the difference between a for and a while loop?


When do we use a for-loop and when a while-loop?


We're here to help

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

© MyTutorWeb Ltd 2013–2025

Terms & Conditions|Privacy Policy
Cookie Preferences