Triangular Numbers - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Triangular Numbers

sangissssangisss Posts: 1Member
How to get the below triangle by programming ?

1 1 1 1
2 2 2
4 4
8

Thanks in advance !

Comments

  • ManishankarManishankar Posts: 5Member
    public class Triange {
    public static void main(String args[])
    {
    int no=1;
    for(int i=4;i>0;i--)
    {
    for(int j=1;j<=i;j++)
    {
    System.out.print(no);
    }
    System.out.println();
    no=no*2;
    }
    }
    }

Sign In or Register to comment.