Factorial HTML
Factorial Coding
<html><head>
<script>
function show(){
var i, no, fact;
fact=1;
no=1;
no=Number(document.getElementById("num").value);
for(i=1; i<=no; i++)
{
fact= fact*i;
}
document.getElementById("answer").value= fact;
}
</script>
</head>
<body>
Enter num: <input id= "num">
<button onclick="show()">Factorial</button>
<input id="answer">
</body>
</html>
Factorial Output
Enter num:
Comments
Post a Comment