Skip to content

Instantly share code, notes, and snippets.

@Mortimer333
Last active March 28, 2018 16:42
Show Gist options
  • Save Mortimer333/cfee3bd68ef8d0a2e8bf3f7386f2f5b5 to your computer and use it in GitHub Desktop.
Save Mortimer333/cfee3bd68ef8d0a2e8bf3f7386f2f5b5 to your computer and use it in GitHub Desktop.
Factorial in Js (html)
<html>
<head>
<title>
JS page
</title>
<meta http-equiv= "Content-Type" content= "text/html; charset=utf-8">
<meta http-equiv= "Content-Language" content="pl">
<script type="text/javascript">
function factorial(n)
{
var factorial=1;
for(i=1; i<=n; i++)
{
factorial=factorial*i;
}
return factorial;
}
</script>
</head>
<body>
<script type="text/javascript">
n=prompt("Pick up a number.","");
eval(n);
document.write(n+" factorial is "+factorial(n));
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment