function factorial(num){ if(num < 2) return 1; return factorial(num-1) * num; } console.log(factorial(5)); //120