Question: 2. Questions 2a through 2d are about the procedure FACTORIAL, which returns the factorial of the integer n. Assume that n0. Use a loop
2. Questions 2a through 2d are about the procedure FACTORIAL, which returns the factorial of the integer n. Assume that n0. Use a loop invariant to prove that FACTORIAL is correct. FACTORIAL(n) f=1 k=1 while kn f=kxf k = k +1 return f 2a. (5 points.) What is a loop invariant for FACTORIAL? 2b. (5 points.) Use the invariant from 2a to prove that FACTORIAL is correct at initialization. 2c. (5 points.) Use the invariant from 2a to prove that FACTORIAL is correct during maintenance. 2d. (5 points.) Use the invariant from 2a to to prove that FACTORIAL is correct at termination.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
