I have to make a few different triangles using nested loops, but I'm really having trouble with this last one.
It's supposed to look like
__________1
________2 1
______3 2 1
____4 3 2 1
__5 4 3 2 1
6 5 4 3 2 1
(not sure if jsp allows blank spaces leading a line, so using _ instead)
The closest I've been able to get is
__________1
________1 2
______1 2 3
____1 2 3 4
__1 2 3 4 5
1 2 3 4 5 6
The code I have is
Code
for(int i=1; i<=6; i++){
for(int j=6; j>=i; j--)
System.out.print(" ");
for(int j=1; j<=i; j++)
System.out.print(j+" ");
System.out.println();
}
Any help is seriously appreciated, I've been staring at this problem for too long....
This post was edited by furbyjs on Feb 18 2014 02:43pm