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

1508 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Write a program that computes the sum of all numbers up to a input number n


What is the difference between & and && operators?


Create a program that takes in two numbers and returns the highest of the two


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


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