Hi, I am working through Hoare Logic problem, I think my invariant is wrong but I cannot think of the good invariant.. please help me with this.
The program:
{n >= 0}
x := 0;
t := 0;
while ( x < n ) do
x := x+1;
t := t+x;
{t = (n^2 + n) / 2}
My invariant was (t = (x^2 +x ) / 2) but it seems that it is wrong


LinkBack URL
About LinkBacks

