Run
<html> <body> <script> function factorial() { var fact=1,i; var a=prompt("enter a number:"); for(i=1;i<=a;i++) { fact=fact*i; } document.write("factorial of number "+a+" is:",fact); } </script> <form> <input type="button" value="factorial" onclick="factorial();"> </form> </body> </html>