Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Factorial Finder</title>
- <script>
- function factorial(n) {
- return n<=1 ? 1 : n*factorial(n-1);
- }
- function displayFactorial() {
- var num = document.getElementById("number").value;
- document.getElementById("result").innerHTML = "Factorial of <b>"+num+"</b> is <b>"+factorial(num)+"</b>";
- }
- </script>
- </head>
- <body>
- <div align="center">
- <h1>Factorial Calculator</h1>
- <input type="number" id="number" placeholder="Enter number">
- <button onclick="displayFactorial()">Calculate</button>
- <p id="result"></p>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement