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

1504 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Which function is ran when an object is instantiated?


Write a function that takes a string, and outputs that string formatted in camelcase. (alternating upper and lower case for each character, e.g. cAmElCaSe)


What are the main data structures that I can use in Python


Write a python function that takes a string as parameter and returns the character in the string with the most occurrences, along with the number of times this character occurs


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