Basic Algorithm Scripting - Factorialize a Number

Tell us what’s happening:
Describe your issue in detail here.
What i’m doing wrong here
Your code so far

var result =0;
function factorialize(num) {
  if (num <= 1) {
    return num * 1;
  return result += factorialize(num * (num - 1))


Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 11; Nokia 3.4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Mobile Safari/537.36

Challenge: Basic Algorithm Scripting - Factorialize a Number

Link to the challenge:

What do the error messages say? What have you tried to fix those messages.

Use of a global variable is a huge red flag. You shouldn’t need a global variable, and using a global variable means you can only ever call your function once.

Maximum call stack size exceeded

Ok. And what have you tried to fix that message?

“Maximum call stack exceeded” means you recursion is never ending.

Are you making the argument to the recursive call smaller here? If not, then you will never have num <= 1.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.