Pattern n umbers and star1

import java.util.;
public class Main {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int nst=1;
int num=n;
for(int i=1;i<=n;i++){
int val=1;
for(int j=1;j<=num;j++){
System.out.print(val+"\t");
val++;
}
if(i>1){
for(int j=1;j<=nst;j++){
System.out.print("
"+"\t");
}

		nst+=2;

	}
	System.out.println();
	n--;

} }}
where i went wrong,correct my code

@karthik1989photos,
In Given, pattern no spaces are there only stars are present.

  • Thinking about variables : nst1 = N, nst2 = -1, cst = 1, rows = 1, total rows = N;
  • Thinking about Value to be printed : row number is to be printed each time at the starting of the row and at the end of the row. So, starting of the row is when out cst is 1 and ending of the row when our cst is nst.

Also, please before sharing your code or asking a doubt, make sure that your code works atleast for the sample test case.

We are here to help you so that you do questions on your own.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.