Skip to content

Instantly share code, notes, and snippets.

@siddharthray
Last active July 17, 2018 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siddharthray/df722746f96bcdb70a2d65244d12c663 to your computer and use it in GitHub Desktop.
Save siddharthray/df722746f96bcdb70a2d65244d12c663 to your computer and use it in GitHub Desktop.
Factorial of a number
<!doctype html>
<html>
<head>
<script>
function show(){
var i, no, fact;
fact=1;
no=document.getElementById("num").value;
for(i=1; i<=no; i++)
{
fact= fact*i;
}
document.getElementById("answer").innerHTML= fact;
}
</script>
</head>
<body>
Enter Num: <input id="num">
<button onclick="show()">Factorial</button>
<h3 id="answer"></h3>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment