Change gcd and lcm to ruby code