-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathfactorial calculation.html
More file actions
98 lines (90 loc) · 2.49 KB
/
factorial calculation.html
File metadata and controls
98 lines (90 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>TrueCodes</title>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css">
<style>
body {
padding: 0;
margin: 0;
background-color: #333;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
}
#Making Container
.container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
background: #b72626;
width: 400px;
height: 200px;
border-radius: 20px;
box-shadow: 0px 0px 40px #000;
}
#Heading
h2 {
text-transform: uppercase;
color: #dedede;
text-align: center;
text-shadow: 0px 0px 10px rgba(0, 0, 0, 1)
}
# Taking input
input {
display: block;
width: 75px;
height: 75px;
border: none;
background: #dedede;
border-radius: 50%;
box-shadow: 0px 0px 20px #262626;
margin: 0 auto;
outline: none;
font-size: 20px;
font-weight: bold;
font-family: 'Lucida Sans';
text-align: center;
}
#Making button
button {
background: #000;
padding: 8px;
border: none;
color: #fff;
font-family: 'Lucida Sans';
font-weight: bold;
border-radius: 20px;
margin-left: 150px;
margin-top: 15px;
outline: none;
cursor: pointer;
transition: .5s;
}
button:hover{
background: #333;
}
</style>
</head>
<body>
<div class="container">
<h2>factorial calculation</h2>
<input id="number" type="number" />
<button id="calc">CALCULATE</button>
</div>
<script>
let calc = document.getElementById("calc");
calc.onclick = () => {
const num = document.querySelector("#number").value;
var arr = 1;
for (var i = num; i > 0; i--) {
arr *= i
}
if (num < 0) {
alert("negative numbers do not have a factorial")
}
alert(arr);
}
</script>
</body>
</html>