Page 1 of 1

Module 6 Assignment Question 1 (20 Points) The Fibonacci sequence starts 1, 1, 2, 3, 5, 8,... Each number in the sequenc

Posted: Sun Jul 03, 2022 11:22 am
by answerhappygod
Module 6 Assignment Question 1 20 Points The Fibonacci Sequence Starts 1 1 2 3 5 8 Each Number In The Sequenc 1
Module 6 Assignment Question 1 20 Points The Fibonacci Sequence Starts 1 1 2 3 5 8 Each Number In The Sequenc 1 (26.28 KiB) Viewed 11 times
Module 6 Assignment Question 1 (20 Points) The Fibonacci sequence starts 1, 1, 2, 3, 5, 8,... Each number in the sequence (after the firs sum of the previous two. Example: 1+1=2 2+3=5 5+8=13 and so on Convert the following algorithm into code for Fibonacci sequence. Use appropriate variab and loops as desired. Approximate answers will be given full credit. Algorithm (Using Recursion): * Function for nth Fibonacci number (This "nth" number is the las the series. Example: If your Fibonacel series is: 0,1,2,3,5,8,13. Then 13 is the "ath" number for you since 13 is the last number sequence. def Fibonacci (n) : Check if input is 0 if input in 0, print incorrect input if 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 elit n - 1 or n - 2: return 1 else: return Fibonacci (n-1)+ Fibonacci (n-2) Output: print (Fibonacci (5)) Your output should be: 0,1,2,3,5. (Since its 5 numbers)