Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript factorial recursion

function factorial(num){
    if(num < 2) return 1;
    return factorial(num-1) * num;
}

console.log(factorial(5)); //120
 
PREVIOUS NEXT
Tagged: #javascript #factorial #recursion
ADD COMMENT
Topic
Name
1+9 =