Question: write two procedures for producing the nth fibonacci number when the number n is given as input. in one procedure, use a for loop and
write two procedures for producing the nth fibonacci number when the number n is given as input. in one procedure, use a for loop and produce the answer using iteration. In the second version use recursion. The input argument and return value should be of type long.
Use the following definition of Fibonccai numbers F0 = F1 and Fn = Fn-1 + Fn-2 for all n>=2.
Have your procedure return -1 if the input argument is negative. Don't worry about overflow.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
