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

Related Python Mentoring answers

All answers ▸

Write a recursive function that takes any integer n and prints the nth Fibonacci number.


What would output this code? print(hello world)


[Student query] Why do we import libraries/modules such as Numpy and Matplotlib into Python?


How do I check if a number is prime using a python program?