Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Program for factorial of a number in javascript

<script>
// Javascript to find factorial
// of given number
 
// function to find factorial
// of given number
function factorial(n) {
  if (n == 0) return 1;
  return n * factorial(n - 1);
}
 
// Driver Code
let num = 5;
document.write("Factorial of " + num + " is " + factorial(num));
 

</script>
Source by www.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #Program #factorial #number #javascript
ADD COMMENT
Topic
Name
2+6 =