How to make a factorial calculator program using Javascript and html.
Learn to make a factorial calculator program using JavaScript and Html.
(2 minutes coding)
1. Open NOTEPAD or NOTEPAD++ in your computer .
2.Copy the code given below .
<!doctype html>
<html>
<head>
<script>
function fac(){
var i, n, fact;
fact=1;
n=parseInt(document.getElementById("num").value);
for(i=1; i<=n; i++)
{
fact= fact*i;
}
document.getElementById("ans").value= fact;
}
</script>
</head>
<body bgcolor= "black" text= "gold" alignment ="center">
<h1>FACTORIAL CALCULATOR</h1><br>
Enter Num: <input id="num" value=0 maxlength=3;>
<br>
                              
<button onclick="fac()">Enter</button>
<br>
      Result=<input id="ans" readonly><br>
</body>
</html>
3. Now paste it in your Notepad file.
4. Now save your file with .html extension.
5. File will appear like this.






Comments
Post a Comment