Fixed div-by-zero bug in extended Euclid