Factorial of a Number

Hi friends  Lets design a webpage which calculated FACTORIAL of a Given Number

Html Code :

<html>
<h2> Calculate FACTORIAL of Number </h2>
<style>
.button {
font-size: 30px;
}
.size {
font-size:30px;
}
</style>
<script>
function factorial()
{
var num=document.getElementById("textbox1").value;
var ans=1;
for(i=num;i>0;i--)
{
ans*=num;
num--;
}
var textbox2=document.getElementById('textbox2');
textbox2.value=ans;
}
</script>
<body>
<input type="text" name="textbox1" class="size" id="textbox1" /><br /> <br />
<input type="submit" name="button" class="button" onclick="factorial()" value="CALCULATE" /><br /> <br />
<input type="text" name="textbox2" class="size" id="textbox2" readonly="true" /><br /><br />
</body>
</html>


You can execute this code at :

http://vitaminjs.kittu.xyz/p/factorial.html

have a Nice Day


See How to do this in

C Language : http://vitaminc.kittu.xyz/2017/12/factorial-of-number.html

Java : http://vitaminj.kittu.xyz/2017/12/factorial-of-agiven-number.html

Python : http://vitaminpy.kittu.xyz/2017/12/factorial-of-number-in-python.html

Comments