JavaScript code:
<HTML>
<HEAD>
<TITLE>
</TITLE>
</HEAD>
<BODY>
<SCRIPT>
var n,m,f=1;
n=m=prompt("Enter a no :");
if(n<0)
{
document.write("Factorial of negative no, can't be determined.");
}
else
{
While(n>0)
{
f=f*n;
n--;
}
document.write("Factorial of "+m+"is= "+f);
}
</SCRIPT>
</BODY>
</HTML>
Output:
Enter a no :10
Factorial of 10 is= 3628800
0 Comments