summaryrefslogtreecommitdiff
path: root/Lab04/fact/index.html
diff options
context:
space:
mode:
authorSaumit Dinesan <justsaumit@protonmail.com>2023-09-13 19:08:54 +0530
committerSaumit Dinesan <justsaumit@protonmail.com>2023-09-13 19:08:54 +0530
commit08dc058cfe1184281fef89c0c484b9e8a6b7a6b7 (patch)
tree834158194e039ef4a76a30752241089f06c87be7 /Lab04/fact/index.html
parentf8a237e363b020e876f553520329046cf813da8e (diff)
Lab04: HTML Form Validation + Factorial
Diffstat (limited to 'Lab04/fact/index.html')
-rw-r--r--Lab04/fact/index.html33
1 files changed, 33 insertions, 0 deletions
diff --git a/Lab04/fact/index.html b/Lab04/fact/index.html
new file mode 100644
index 0000000..a6f7456
--- /dev/null
+++ b/Lab04/fact/index.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-7">
+ <meta name="viewport" content="width=device-width, initial-scale=2.0">
+ <link rel="stylesheet" href="style.css">
+ <title>Factorial Calculator</title>
+</head>
+<body>
+ <h1> Factorial </h1>
+ <p>Factorial is a mathematical operation that involves the multiplication of a positive integer with all the smaller positive integers leading up to it. <br>It is denoted by the symbol "!" following a number. <br> For instance, the factorial of 5 (written as 5!) equals the product of 5 × 4 × 3 × 2 × 1, resulting in 120. </p>
+ <div>
+ <label for="numberInput">Enter a number:</label>
+ <input type="number" id="numberInput">
+ </div>
+ <button type="submit" id="submitbutton">Submit</button>
+ <p id="result"></p>
+ <script>
+ function factorial(n) {
+ if (n==0){
+ return 1;
+ }
+ return n*factorial(n-1);
+ }
+ const button = document.getElementById("submitbutton")
+ button.addEventListener("click", function() {
+ const input = document.getElementById("numberInput").value;
+ const result = factorial(input)
+ document.getElementById("result").innerText=`The factorial of ${input} is equal to ${result}`;
+ });
+ </script>
+</body>
+</html>