Skip to content

Commit ba5bbb0

Browse files
authored
Create 06_Number_Full_Pyramid.js
1 parent 1a1ac36 commit ba5bbb0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Q21: Print full pyramid with numbers
2+
// 1
3+
// 222
4+
// 33333
5+
// 4444444
6+
// 555555555
7+
8+
let n = 5;
9+
10+
for (let i = 1; i <= n; i++) {
11+
let spaces = " ".repeat(n - i);
12+
let numbers = String(i).repeat(2 * i - 1);
13+
console.log(spaces + numbers);
14+
}

0 commit comments

Comments
 (0)