calculate gcd(m, n)