Question: The loop below computes the sum k = 1 n k 2 : While ) ( n sum : = sum + j 2 j

The loop below computes the sum k=1nk2 :
While )(n
sum := sum +j2
j:=j+1
End-while
Pre-condition: m and n are non-negative integers. j=1 and sum =0.
Post-condition: ??=k=1nk2.
Loop- invariant: j is an integer, jn+1, and ??=k=1j-1k2.
What facts are assumed in proving the post-condition?
j is an integer
jn and jn
??=k=1j-1k2
j is an integer
jn+1 and jn
sum =k=1j-1k2
j is an integer
jn and j>n
??=k=1j-1k2
j is an integer
j=n
??=k=1j-1k2
The loop below computes the sum k = 1 n k 2 :

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 Programming Questions!