import java.util.Scanner;
public class demo1
{
public static void main(String[] args)
{
int i,j,n,s,k;
System.out.print ("Input number of rows : ");
Scanner input = new Scanner(System.in);
n = input.nextInt();
s=n+4-1;
for(i=1;i<=n;i++)
{
for(k=s;k!=0;k--)
{
System.out.print(" ");
}
for(j=1;j<=i;j++)
{
System.out.print(i+" ");
}
System.out.println();
s--;
}
}
}Java
Program to print a pattern like a pyramid.

Written by
View ProfileNikhil Juneja
Passionate software developer and technical contributor at TutorialsLink.
