function - factorial in javascript without looping -


this question has answer here:

how factorial works without while or loop cant understand please explain

function factorial(x) {      if (x === 0) {      return 1;    }    return x * factorial(x - 1);    }  console.log(factorial(5));

it uses recursive function. factorial calls many times, long x not 0.


Comments

Popular posts from this blog

html - How to custom Bootstrap grid height? -

javascript - pass values from mssql to views in node -

javascript - Understanding ExtJS Framework Syntax -