Display Traingle as follow in java

Ram Pothuraju
1
2 3
4 5 6
7 8 9 10...N

Program ::



 class triangle
{
            public static void main(String args[])
            {
                        int i,j,n=4,k=1;
                        for(i=0;i<n;i++)
                        {
                                    for(j=0;j<=i;j++)
                                    {
                                                System.out.print(" "+k);
                                                k++;
                                    }
                                    System.out.println();
                        }
            }
}
Tags

Post a Comment

0Comments

Post a Comment (0)