Given a limit the task is to generate the below given pattern.
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
Where limit = 5
Java
import java.util.*;
public class PatternV8
{
public static void main(String args[])
{
int n=0;
Scanner sc=new Scanner(System.in);
System.out.print("Enter a limit: ");
n=sc.nextInt();
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n-i;j++)
{
System.out.print(" ");
}
for(int j=i;j>=1;j--)
{
System.out.print(j+" ");
}
System.out.println();
}
}
}Java