I am trying to get the below pattern:
**
*
Instead I am getting this pattern:
My code is as below:
public static void patt5(int n){
int row = 1;
int nst = n;
int nsp = 0;
// row work
while(row <= n){
// space work
int asp = 1;
while(asp <= nsp){
System.out.print(" “);
asp++;
}
// star work
int ast = 1;
while(ast <= nst){
System.out.print(”* ");
ast++;
}
// prep
System.out.println();
nst -= 1;
nsp += 1;
row += 1;
}
}
Please suggest what is wrong with the code.