-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPyramid.html
45 lines (38 loc) · 1.06 KB
/
Pyramid.html
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
<!DOCTYPE html>
<html>
<head>
<title>Pyramid Generation</title>
</head>
<body>
<form>
<table>
<tr>
<td>Enter Number:</td>
<td><input type="number" placeholder="Enter the amount" id="element"></td>
</tr>
<tr>
<td><button type="button" onclick="pyramid()">Submit</button></td>
</tr>
</table>
</form>
<h4>The Pattern Generaated is-:</h4>
<br>
<div id="output">
</div>
</body>
<script>
function pyramid(){
var N = document.getElementById("element").value;
console.log(N);
var div = document.getElementById("output")
N = parseInt(N);
for(var i=0;i<(N+1);++i){
for(var j=N;j<=N+i;++j){
div.insertAdjacentHTML("beforebegin",j);
div.insertAdjacentHTML("beforebegin"," ");
}
div.insertAdjacentHTML("beforebegin","<br>");
}
}
</script>
</html>