What is the Loop Invariant(s) in this sample code.
This is an excerpt code implemented in C programming language:
//pre-condition m,n >= 0
x=m;
y=n;
z=0;
while(x!=0){
if(x%2==0){
x=x/2;
y=2*y;
}
else{
x=x-1;
z=z+y;
}
}//post-condition z=mn
These are my initial answers (Loop Invariant):
y>=n
x<=m
z>=0
I am still unsure about this. Thanks.