Using Euclidean algorithm for solving relatively primes.