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

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

Ansible warning on jinja2 braces on when -