Problem Statement:
Create a script to find the factorial of a given number.
Source Code:
ex6.html
Exercise - 6
ex6script.js
function fact(n) { if(n == 0 || n == 1) return 1; else return n * fact(n - 1); } var num = Number(prompt("Enter a number: ")); document.write("Factorial of " + num + " is: " + fact(num));
Output:
Click here
for output