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

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

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -