Floid's Trangle
import java.util.*;
// import java.util.Scanner;
public class practice {
public static void invertedhalfpryaminnumberpattern(int n){
int k=1;
for(int row=1;row<=n;row++){
for(int col=1;col<=row;col++){
System.out.print(k+" ");
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