Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Help finding a loop invariant.

Name: Anonymous 2006-12-08 10:24

Can someone help me find a loop invariant. The problem is,

x = a, y = b, s = 0
where A and B > 0.

while x =/= 0 do(
while x is even do (y= 2*y, x = x/2),
s = s+y, x=x-1)

when this loop finishes s = a*b

I need to find a loop invariant that is semantically equivalent to s=a*b

So when the loop starts it says s=0 and when the loop finishes it says s=a*b

Name: Anonymous 2006-12-08 11:45

s=ab-xy

Name: Anonymous 2006-12-09 12:44

looks like youre trying to multiply like a russian peasant.

Name: Anonymus 2006-12-13 8:16

>>3
Easy.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List