Question: Write a python program that computes the Fibonacci number for some input integer. The Fibonacci sequence is defined as the first two elements are each

Write a python program that computes the Fibonacci number for some input integer. The Fibonacci sequence is defined as the first two elements are each 1, after that each element in the sequence is the sum of the previous two elements. The first few numbers of the sequence are 1,1,2,3,5,8,13,21,34,55,

Your assignment is to write a program with the main function and two additional functions. The main function will request the index into the Fibonacci sequence that is desired and verify that it is a positive integer. If it is not a positive integer, it will request that the use input a number again. Note that I will test this using letters, decimal numbers, negative integers, etc. and it must handle these problems without erroring off (hint - use a while loop and a try block). It will do so until the use inputs a positive integer. It will then invoke the two functions each of which will compute the required Fibonacci number. One function will use recursion to do so and another will use iteration. Your main function will output the determined Fibonacci number from each of the methods (they had better be the same).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!