This exercise contains a while loop and a predicate. loop: while (m ≥ 0 and m ≤ 100) m := m + 4 n := n − 2 end while predicate: m + n is odd Fill in the blanks to show that if the predicate is true before entry to the loop, then it is also true after exit from the loop. Suppose m + n is odd before entry into the loop. Suppose m + n is odd before entry into the loop. Let new + new denote the values of m and n after exit from the loop. Find and simplify an expression for new + new in terms of m and n.

Respuesta :

Answer:

m' + n' = m + n + 2

Step-by-step explanation:

We are told that m + n is odd before entry into the loop. So let, P(q) be m + n is even on qth iteration of the while loop

Our basis step will be q = 0.

So, let P(k) be true and we can say that m + n is odd on the kth iteration of the while loop

Now, we need to prove that P(k + 1) is true.

Thus, on the (k + 1)th iteration, m is increased by 4 and n is decreased by 2.

Let's call the new values m' and n'.

So, m' = m + 4 and n' = n - 2

Thus, m' + n' = m + 4 + n - 2 = m + n + 2