Question: 1 . The following recursive algorithm takes an integer parameter n and returns the nth Fibonacci number. The Fibonacci numbers are as follows: 0 ,
The following recursive algorithm takes an integer parameter n and returns the nth Fibonacci number. The Fibonacci numbers are as follows: etc. We can expect fib fib fib fib etc.
In general, fibn fibn fibn
Prove the function fib is correct.
Precondition: n is a nonnegative integer
Postcondition: fib returns Fibonacci value of n
long fiblong n
if n n
return n;
else
return fibn fibn;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
