Factorial of the input number
Factorial of a number is product of all integers from 1 up to the number ( inclusive ).
Factorial of 5 is 1*2*3*4*5 = 120
Or
n! = 1*2*3….n
Enter a number here
Output here
<html>
<head>
<title></title>
</head>
<body>
<input type="text" name="t1" id="t1">
<input type="button" value="Submit" onclick="show_factorial()">
<div id=d1></div>
<script type="text/javascript">
function show_factorial(){
x=document.getElementById("t1").value
x=parseInt(x)
if(Number.isInteger(x)){
b=1
for (i=1;i<=x;i++){
b=b*i
}
document.getElementById('d1').innerHTML="Factorial of "+x+" is : "+b
}else{
document.getElementById('d1').innerHTML="Enter an Integer "
}
}
</script>
</body>
</html>
Next lower value of any decimal number →
← JavaScript Basic JavaScript variable →
←JavaScript Math Reference
← Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
plus2net.com