Sample Input
5
Sample Output
1 2 3 4 5
1 2 3 4 *
1 2 3 * * *
1 2 * * * * *
1 * * * * * * *
This is the pattern
This is my corresponding java code:
import java.util.*;
public class pattern {
public static void main(String [] args) {
Scanner sc= new Scanner(System.in);
int N=sc.nextInt();
for(int i=1; i<=N; i++) {
for(int j=N; j>=i; j--) {
System.out.print(N-j+1+" ");
}
if(i!=1) {
for(int k=1; k<2*i-2;k++) {
System.out.print("* ");
}
}
System.out.println();
}
sc.close();
}
}
Kindly help