Finding Factorial of Number using Recursive and It

Run Settings
LanguageJavaScript
Language Version
Run Command
// Write two functions that finds the factorial of any number. One should use recursive, the other should just use a for loop let answer=1; function findFactorialRecursive(number) { //code here if(number===2){ return 2; } else if(number===0 || number===1){ return 1; } return number * findFactorialRecursive(number-1); } function findFactorialIterative(number) { //code here if(number===0 && number===1){ return 1; } for(let i=number;i>0;i--){ answer=answer*i; } return answer; } findFactorialIterative(0) findFactorialRecursive(4)
Editor Settings
Theme
Key bindings
Full width
Lines