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

Ansible warning on jinja2 braces on when -

Parsing a protocol message from Go by Java -

node.js - Node js - Trying to send POST request, but it is not loading javascript content -