Pattern numbers star 1

import java.util.;
public class Main {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int i,j;
for(int i=n;i>0;i–)
{
for(int j=0;j<i;j++)
{
System.out.print(j+" ");
}
for(int j=0;j<2
(n-i)-1;j++)
{
System.out.print("*");
System.out.print(" ");
}
System.out.println();

} }

sir can u help where i went wrong

@karthik1989photos,
https://ide.codingblocks.com/s/264226 corrected code.

Mistake:
do:

			for (int j = 1; j <= i; j++) {

Start j from 1 and go till <=i instead of j=0 to j<i.

Rest your logic is correct :slight_smile:

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.