Can anyone please tell me what the loop invariant of this code is?
int a = n;
int b = 0;
while ( a > 0 )
{
a--;
b = b + 2;
}
At first, I thought n, but it’s wrong…
After reading stuff about loop invariants, I think it’s a>0 and b = b+2, because they both hold true…
So, what’s the loop invariant?
Thanks. :beam: