Question: Prove the iterative fibonacci program by total correctness (i.e, that is loop invariant, termination, partial correctness etc) Precondition: n ? Postconditon: Return the nth Fibonacci

Prove the iterative fibonacci program by total correctness (i.e, that is loop invariant, termination, partial correctness etc)

Precondition: n ? Prove the iterative fibonacci program by total correctness (i.e, that is loop

Postconditon: Return the nth Fibonacci number, in which the sequence begins as {1, 1, 2, 3, . . .}

fib(n):

1. a = 1; b = 1; c = 2; d = 1

2. while c

3. d = a + b

4. a = b

5. b = d

6. c = c + 1

7. return d

Transcribed image text

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!