Skip to content

Commit 3a5a6db

Browse files
Merge pull request #166 from Dipalikamboj/patch-1
Hacktoberfest2023
2 parents c066e5e + f15612b commit 3a5a6db

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

pattern.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Java Program to print pattern
2+
// Number triangle pattern
3+
import java.util.*;
4+
5+
public class GeeksForGeeks {
6+
// Function to demonstrate pattern
7+
public static void printPattern(int n)
8+
{
9+
int i, j;
10+
// outer loop to handle number of rows
11+
for (i = 1; i <= n; i++) {
12+
// inner loop to print space
13+
for (j = 1; j <= n - i; j++) {
14+
System.out.print(" ");
15+
}
16+
// inner loop to print star
17+
for (j = 1; j <= i; j++) {
18+
System.out.print(i + " ");
19+
}
20+
// print new line for each row
21+
System.out.println();
22+
}
23+
}
24+
25+
// Driver Function
26+
public static void main(String args[])
27+
{
28+
int n = 6;
29+
printPattern(n);
30+
}
31+
}

0 commit comments

Comments
 (0)