forum

Home / DeveloperSection / Forums / nested for loop in java for a triangle

nested for loop in java for a triangle

Anonymous User256510-May-2013
Hi Expert

I have been trying to create a triangle in this sequence:

1
21
321
4321
54321

(without the gaps in between )

even though my syntax is correct, I have been going through logical errors with non-terminating loops.
this is the program which I'm trying to fix:
for(i=1;i>=1;i++)
    {
        for(j=i;j<=i;j=j-1)
        {
            System.out.print(j);        
        }
        System.out.println(); 
    }
help would really be appreciated for this.

Thanks in advance! 

Updated on 10-May-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By