Hiya. So here's a question:
I've got a pseudocode algorithm
How do I prove that with all x values the algorithm terminates, a.k.a regardless of the value of x in the beginning the algorithm will produce a number from the initial x that is of form (x = x*2n)?
I've got a pseudocode algorithm
MODULE stupidmodule(INTEGER x)
WHILE x>1 DO
IF even(x) THEN (* x is even*)
x:= x/2
ELSE
x:= 3*x+1 (* x is odd *)
ENDIF
ENDWHILE
ENDMODULE
How do I prove that with all x values the algorithm terminates, a.k.a regardless of the value of x in the beginning the algorithm will produce a number from the initial x that is of form (x = x*2n)?