[Solved] Java pyramid program print numbers? [closed]


just make a small modification.i declared a variable int z = 0; each time it print a character increment z by one.because this pattern goes like 0,1 ,2 ,3 ,4 ,++++.......

int levels = 4;
int z = 0; // this make it easy
for (int i = 0; i < levels; i++) {
    for (int s = levels; s > i; s--) {
        System.out.print(" ");
    }
    for (int j = 0; j <= i; j++) {

        System.out.print(z + " ");
        z++;
    }
    System.out.println("");
}

the output

    0 
   1 2 
  3 4 5 
 6 7 8 9 

solved Java pyramid program print numbers? [closed]