I am having some issues finding the invariant for the algorithm below.Also,I have to follow all the steps to proof how i find the specific invariant and I don't know how I can demonstrate that. I saw that this algorithm is a multiplication by adding.
The algorithm is:
alg1(integer a,b)
x<-a
y<-b
z<-0
while y>0 do
z<-z+x
y<-y-1
end while
return z
I hope someone can help share some light on this for me, as the similar cases I've found in here, have not been sufficient.
Thanks alot in advance for your time.