A loop invariant is a condition that is true before entering the loop, and remains true after each iteration of the loop. When the loop terminates, the loop invariant, combined with the loop termination condition, should imply the correctness of the
Show more…