+ 2
I need help on creating a pyramid
Hi! I can't seem to produce this output. Any help will be appreciated. 1 2 4 6 3 6 9 12 15 4 8 12 16 20 24 28
3 Respostas
+ 2
What you tried so far..? Can we see..?
For j=1 to 2*n
Do print spaces in n-r and n+r values of j, else print number..
0
this is what I got so far.
int rowss=5, kk=0;
for(int ii=1; ii<=rows; ++ii, kk=0) {
for(int spacee=1; spacee<=rowss-ii; ++spacee) {
System.out.print(" ");
}
int number=1;
while(kk!=2*ii-1) {
System.out.print(number+" ");
number++;
++kk;
}
System.out.println();
0
Set
int number=ii; //instead of int number=1;
In while loop, change number++ to
number = number + ii;