I am trying to implement a algorithm for the GCD of two numbers in a functional approach. Can this be improved further, also with regards to performance?
def gcd(a, b)
return b if a ==0
return a if b == 0
return b if (a%b == 0)
return a if (b%a == 0)
(a > b)? gcd(a, a%b) : gcd(b%a, b)
end