Update Euclid's algorithm