Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Factorial in javascript

function factorial(n) {
    if (n == 1) {
        return 1;
    }
    return n * factorial(n - 1);
}
console.log(factorial(6));
//Output: 720
Source by www.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #Factorial #javascript
ADD COMMENT
Topic
Name
3+9 =