Send me the program for below output
0
101
21012
3210123
432101234
54321012345
Code :-
public class Pattern1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System. in);
int num = sc.nextInt();
int count = 5;
boolean flag = false;
for (int i = 0; i <= num; i++) {
for (int j = 0; j <= 2*num; j++) {
if(count == 0) {
flag = true;
}
if(count <= i) {
System.out.print(count + " ");
} else {
System.out.print(" ");
}
if(flag) {
count++;
} else {
count--;
}
}
System.out.println();
count = 5;
flag = false;
}
}
}