R
R
Roman Makarov2016-01-10 04:16:45
recursion
Roman Makarov, 2016-01-10 04:16:45

Why is the recursive function in node.js calling 500?

There is a module that has a factorial calculation function

MMINF.prototype.factorial = function (n) {
    return (n != 1) ? n * this.factorial(n - 1) : 1;
};

the error sounds like this:
RangeError: Maximum call stack size exceeded

Is it impossible to work with recursion in a node or am I missing something obvious?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question