Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head lang="en">
- <meta charset="utf=8">
- <title>Exercise</title>
- </head>
- <body>
- <h1>Exercise</h1>
- <h3 id="message"></h3>
- <script>
- var result = 1;
- var numInput = Number(prompt("Factorial calculation: please enter a number"));
- for (i = 2; i <= numInput; i++) {
- result = result * i;
- }
- var htmlRef = document.getElementById("message");
- htmlRef.textContent = numInput + "! = " + result;
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement