Extended Euclidean Algorithm, Stinson pg 160
Stinson's algorithms return r as the gcd(a,b), when the algorithm in fact only terminates when r=0.
The return line should read:
return (r=min(a0, b0), s, t)This takes care of both the case where the loop is entered, and the case where b|a or a|b, and the main while loop is not entered.
Multiplicitive Inverse Algorithm, Stinson pg 161
Similar modifications must be made here, as for EEA. The end should read:
if b0 != 1
then b has no inverse modulo a
else return (t)