SUR- and sc were will Using Reco IT it is posen interes Ligut LEA - 01 then it will turn wilf - elsor return o Check if
Posted: Sun Jul 03, 2022 11:22 am
Module 6 Assignment Question 1 (20 Points) The Fibonacci sequence starts 1, 1, 2, 3, 5, 8. Each number in the sequence (after the first two) is the sum of the previous two Example: 2+3=5 5+8-13 and so on Convert the following algorithm into code for Fibonacci sequence. Use appropriate variables, functions, and loops as desired. Approximate Algorithm (Using Recursion): Function for ath Fibonacci number (This "ath" number is the last number i the series. answers will be given full credit. Example If your Fibonacci series is: 0,1,2,3,5,8,13. Then 13 is the "nth" ausber for you since 13 is the last number in the sequence. def Fibonacci (n): Check it input is 0 if input is 0, print incorrect input it n < 0: print("Incorrect input"). Check if n is 0 #then it will return 0 elif n 0: return 0 Check if n is 1,2 it will return 1 elif n-1 or n 2:: return 1 else: return Fibonacel (n-1) Fibonacci (n-2) Output: print (Fibonacci (5)) Your output should be: 0,1,2,3,5. (Since its 5 numbers)