<!DOCTYPE html>
<html>
<head>
</head>
<body style = "text-align: center; font-size: 20px;">
Enter a number: <input id = “num”>
<br><br>
<button onclick = "fact()"> Factorial </button>
<p id = "res"></p>
<script>
function fact(){
var i, num, f;
f = 1;
num = document.getElementById("num").value;
for(i = 1; i <= num; i++)
{
ff = f * i;
}
ii = i – 1;
document.getElementById("res").innerHTML = "The factorial of the number " + i + " is: " + f ;
}
</script>
</body>
</html>
_________________________________________________________________________________________________________________
/*factorial*/
<html>
<head>
<title>factorial</title>
</head>
<script>
val=prompt("Enter a number:", "”")
j=1;
for (i=1; i<=val; i++)j=j*i;
alert("The factorial of " + val + “" is "+j)
</script>
</html>