Euclidean algorithm for GCD