I have this code:
def FirstFactorial(num)
num == 0 ? 1 : num * FirstFactorial(num - 1)
return num
end
however, the result keeps returning the original argument. How can I return the result created by my ternary operator?
It returns the argument because you told to do so. Try this.
def FirstFactorial(num)
return (num == 0 ? 1 : num * FirstFactorial(num - 1))
end