Coding Solution: Reverse Pyramid Pattern in JAVA

Here, r= Rows, s=space, i & j are rows and columns respectively, for increment and decrement of pattern serially.

Code: 

class Main
{
public static void main(String[] args)
{
int r=5;
for(int i=r;i>=1;–i)
{
for(int s=1; s<=(r-i); ++s)
{
System.out.print(” “);
}
for(int j=i; j<=(2i-1);++j) { System.out.print(” “);
}
for(int j=0;j<(i-1);++j)
{
System.out.print(“*”);
}
System.out.println();
}
}
}

Output: 

Leave a comment