# The loop invariant

Computer Science Level 2
 1 2 3 4 5 p=1 i=0 while p

Consider the above fragment of code, with $$n$$, $$p$$ and $$i$$ as integer variables. What is the loop invariant of the code?

Definition: A loop invariant is a condition that is necessarily true immediately before and immediately after each iteration of a loop

×