Question: You can use the given loop invariant without proof. 1 / / pre: n > = 1 2 a 3 * n 3 sum 0

You can use the given loop invariant without proof.
1// pre: n >=1
2 a 3*n
3 sum 0
4// LoopInv: a is divisible by 3
5 while (a >0)
6 b 0
7 while (b < a)
8 sum sum +2*b
9 b b+1
10 a a-3
Calculate the value of the variable sum when the program terminates, as
a function of the input n.

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!