1 2 3 4 5 |
|
Consider the above fragment of code, with , and 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
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Hence, by induction, after any iteration p = 2 i holds.