Inverted Half piramid with numbers
import java.util.*;
// import java.util.Scanner;
public class practice {
public static void invertedhalfpryaminnumberpattern(int n){
int k=0;
for(int row=1;row<=n;row++){
for(int col=1;col<=n-k;col++){
System.out.print(col);
}
k++;
System.out.print("\n");
}
}
public static void main(String[] args) {
Scanner s =new Scanner(System.in);
int n;
System.out.println("Enter the size of square matrix");
n=s.nextInt();
invertedhalfpryaminnumberpattern(n);
}
}
Output -
Comments
Post a Comment