Page

Find the factorial number using java script

<html>
<head>
<script>
function factorial()
{
a = prompt("enter a number","");
fact = 1;
for(i=1;i<=a;i++)
{
fact =fact*i;
}

document.write("factorial of number is " +fact);
}
</script>
</head>
<body>
<button onclick="factorial()">Try it</button>
</body>
</html>

No comments:

Post a Comment