Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Factorial while loop reverse in javascript

function myFactorial(number) {
    var fact = 1;
    var i = number;
    while (i >= 1) {
        fact = fact * i;
        i--;
    }
    return fact;
}
console.log(myFactorial(6));
//Output: 720;
 
PREVIOUS NEXT
Tagged: #Factorial #loop #reverse #javascript
ADD COMMENT
Topic
Name
4+3 =