Spring 2001 CS100M Solutions to Bonus Exercise E4 1. (last student is from M) = (m is odd). note: You might be more used to seeing "if and only if" instead of "=". 2. inv: The parity (remainder mod 2) of the number N of M students is constant Proof by case analysis on the loop body: + if both students are from M, then N <-- N-2, so parity is unchanged. + else (either or both are from J) N is unchanged, so parity is unchanged. Remark: The loop invariant ("storyline") is a powerful tool that clearly and succinctly explains what is happening!