1

Why is a simple regular recursion in Elixir not giving stack overflow exception even with very high number like n = 500000? It is neither tail recursion nor TCO.

def factorial(n) do
    cond do
        n == 0 ->
            1
        true ->
            n * factorial(n - 1)
    end
end
Manvi
  • 1,136
  • 2
  • 18
  • 41
  • The answer in the question I voted to close this as a duplicate of applies to Elixir as well: http://stackoverflow.com/a/38968304/320615 – Dogbert Sep 26 '16 at 04:49

0 Answers0