Sort by

recency

|

295 Discussions

|

  • + 0 comments
    function factorial(num){
        let result = 1;
        for (let x = 1; x<num+1 ;x++ ){
            result = result * x 
        }
        return result
    }
    
  • + 0 comments

    function factorial(n) { let countDown = n; let result = 1;

    while (countDown > 0) { result *= countDown; countDown--; } return result; }

  • + 0 comments

    function factorial(n){ let result = 1 for(let i=1;i<=n;i++){ result=i*result // yfy } return result; }

  • + 1 comment
    function factorial(n) {
        return (n === 0 || n === 1) ? 1 : n * factorial(n - 1);
    }
    
  • + 0 comments
    function factorial(n){
        if (n===0 || n===1){
            return 1;
        }
        else {
            return n * factorial(n-1);
        }
    }