Skip to content

Commit 717d539

Browse files
committed
feat: Generate inverted triangle number pattern with formatted counter
🧠 Logic: - Use a counter variable starting from 1. - Outer loop runs from 1 to 5 (for rows). - Inner loop prints (5 - i + 1) numbers per row. - Format numbers with leading zeros using `%02d` for uniform width. Signed-off-by: Somesh diwan <[email protected]>
1 parent 74ea5a8 commit 717d539

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Section8LoopAB/src/PatternsAB9.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ public class PatternsAB9 {
22
public static void main(String[] args) {
33
int count =0;
44

5-
for (int i =1; i<=5; i++)
6-
{
7-
for (int j=1; j<=5-i+1; j++)
8-
{
5+
for (int i =1; i<=5; i++) {
6+
for (int j=1; j<=5-i+1; j++) {
97
count++;
108
System.out.format("%02d ",count);
119
}
1210
System.out.println("");
1311
}
1412
}
15-
}
13+
}

0 commit comments

Comments
 (0)