The following would cause stack overflow for large 'n', and I can understand why.
def factorial(n)
(n > 1) ? (return (n * factorial(n - 1))) : (return 1)
end
Why does the following cause overflow as well?
def factorial(n, k)
(n > 1) ? (return factorial(n - 1, lambda {|v| return k.call(v * n)})) : (return k.call(1))
end