Find Factorial in JavaScript

Learn how to findĀ factorial in javaScript

<html>
<body>
<script type=”text/javascript”>

var n = prompt(“Enter a number :: “);

var fact=1;

for(var i=1;i<=n;i++)
{
fact*=i;
}

document.write(“Factorial of a given number is :: “+fact);

</script>
</body>
</html>

 

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.