Take N (number of rows), print the following pattern (for N = 5)
1
2 2
3 0 3
4 0 0 4
5 0 0 0 5
test cases are not passing but pattern is printing correct.
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
scn.close();
int row=1;
int tot_st=1;
// int x=0;
while(row<=n) {
int cnt_st=0;
int num=row;
while(cnt_st<tot_st) {
if (cnt_st==0||cnt_st==row-1) {
System.out.print("\t"+num+"\t");
}
else {
System.out.print("\t0\t");
}
cnt_st++;
}
System.out.println();
row=row+1;
tot_st++;
}
}
}