-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
85 lines (72 loc) · 1.97 KB
/
index.html
File metadata and controls
85 lines (72 loc) · 1.97 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div{
border: 2px solid blue;
display: inline-block;
margin-left: 100px;
}
p{
color: red;
}
#shivam:hover{
}
#button{
color: red;
background-color: rgb(32, 18, 216);
text-align: center;
margin-left: 30px;
}
#button:hover{
background-color: aqua;
border: 2px solid green;
}
#print{
background-color: rgb(26, 30, 24);
display: inline-block;
margin-left: 30px;
margin-right: 30px;
border-radius: 05px;
}
H1{
color: red;
}
</style>
<script>
function fact(){
var num;
var sum=1;
var p=document.getElementById('print');
num=Number(document.getElementById('shivam').value);
if(num<0){
p.innerHTML="please enter a positive value"
}
else if(num==0){
p.innerHTML=1;
}
else{
for(var i=1;i<=num;i++){
sum=sum*i;
}
p.innerHTML="factorial is "+sum ;
}
}
</script>
</head>
<center>
<body>
shivam
<h1>SHIVAKANT SHUKLA </h1>
<div>
<p><input id="shivam" type="text" placeholder="enter a number"></p>
<p><input id="button" type="button" value="print factorial" onclick='fact()'></p>
<p id="print"></p>
</div>
</center>
</body>
</html>