Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

While loop factorial function in javascript

function myfact(number) {
   var fact = 1;
    var i = 1;
    while (i <= number) {
        fact = fact * i;
        i++;
    }
    return fact;
}
console.log(myfact(6));
//Output: 720
 
PREVIOUS NEXT
Tagged: #While #loop #factorial #function #javascript
ADD COMMENT
Topic
Name
3+9 =