Inverted half pyramid with row's numbers pattern in java.
import java.util.*;
public class pattern {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("enter the row no.=");
int n=sc.nextInt();
for(int i=1; i<=n; i++){
for(int j=n; j>=i; j--){
System.out.print(i+" ");
}
System.out.println();
}
}
}
■》Output->
enter the row no= 5
1 1 1 1 1
2 2 2 2
3 3 3
4 4
5
Comments
Post a Comment