Realized euclid algorithm of getting greatest common divisor