Prove correctness of iterative LCM algorithm
Assume j, k > 0. 

You have your loop invariant. Every iteration, one of c or d gets larger. They cannot forever stay ≤ LCM (i, j), therefore the loop must finish. 

Because c and d are multiples of i, j, they cannot change directly from being &lt; LCM (i, j) to > LCM (i, j), instead there must be a step for each of c and d where it is equal. 

If both are = LCM (i, j) then c = d and the algorithm exits. If one is = LCM (i, j) then the other one is smaller and gets increased.