Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3cba033

Browse files
feat: add pattern programming triangle pattern
1 parent 83272a7 commit 3cba033

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎Topic4/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,16 @@ for (let i = 1; i <= 5; i++) {
115115
}
116116
console.log();
117117
}
118+
119+
// triangle pattern
120+
let n = 5;
121+
122+
for (let i = 1; i <= n; i++) {
123+
for (let j = 1; j <= n - i; j++) {
124+
process.stdout.write(" ");
125+
}
126+
for (let k = 1; k <= 2 * i - 1; k++) {
127+
process.stdout.write("*");
128+
}
129+
console.log();
130+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /