Skip to content

Commit 3e3d5eb

Browse files
authored
Merge pull request #6 from philomathtanya/master
Create Pyramid.java
2 parents 67a2cc0 + 268a948 commit 3e3d5eb

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

Pyramid.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
public class JigSawAcademy
2+
3+
{
4+
5+
public static void PyramidPattern(int n)
6+
7+
{
8+
9+
for (int i=0; i<n; i++) // for number of rows(n)
10+
11+
{ for (int j=n-i; j>1; j–) // a loop for spaces
12+
13+
{
14+
15+
System.out.print(” “); //to print space
16+
17+
}
18+
19+
for (int j=0; j<=i; j++ ) //for number of columns
20+
21+
{
22+
23+
System.out.print(“* “); //to print star
24+
25+
}
26+
27+
System.out.println(); //end-line after every row
28+
29+
}
30+
31+
}
32+
33+
public static void main(String args[]) //driver function,
34+
35+
{
36+
37+
int n = 5;
38+
39+
PyramidPattern(n);
40+
41+
}
42+
43+
}

0 commit comments

Comments
 (0)