fix infinite loop in gcd as b approaches infinity