Exercise 3, p. 118

Function to return the value of tex2html_wrap_inline181 for x, tex2html_wrap_inline185

tex2html_wrap_inline187

  1. tex2html_wrap_inline189 , so this is valid.
  2. Assume Q(k), and consider Q(k+1):

    displaymath179

    using the tex2html_wrap_inline195 case. So we have verified the loop invariant by induction.

  3. At termination: tex2html_wrap_inline197 , hence tex2html_wrap_inline199 .

Exercise 8, p. 118

displaymath201

so gcd(1018215,2695)=55, by the Euclidean algorithm.

Exercise 13, p. 120

tex2html_wrap_inline207

Note in particular that i is stepping down in this case by 1, rather than up as it has in the other examples.

  1. tex2html_wrap_inline211 , so this is valid.
  2. Assume Q(k), and consider Q(k+1):

    displaymath205

    using the tex2html_wrap_inline195 case. So we have verified the loop invariant by induction.

  3. At termination: tex2html_wrap_inline219 , so tex2html_wrap_inline221 .



LONG ANDREW E
Mon Feb 4 17:38:40 EST 2002