Add promotion, extended euclidean algorithm now works with modular ints.