In Python, write a recursive function that returns the first n Fibonacci numbers.

Begin by denoting the first and second Fibonacci number as 0 and 1 respectively. This helps us define a base case for our algorithm. We know that new Fibonacci numbers are formed by adding its 2 predecessors. This will help us define the recursive call.
Code:def Fibonacci(n): if n == 0: return 0 elif n == 1: return 1 else: return Fibonacci(n-1)+Fibonacci(n-2)

Answered by Meer S. Computing tutor

1338 Views

See similar Computing A Level tutors

Related Computing A Level answers

All answers ▸

Explain how the fetch execute cycle works? Include the specific registers and buses being used


What is the denary equivalent of the hexadecimal number A7?


Describe the operations of an optical disk drive used to read data from an optical disk, such as a CD or DVD.


When data is transmitted over long distances, latency can become an issue. Explain what latency is.


We're here to help

contact us iconContact usWhatsapp logoMessage us on Whatsapptelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo
Cookie Preferences