Triangular Numbers

How to get the below triangle by programming ?

1 1 1 1
2 2 2
4 4
8

Thanks in advance !

Comments

  • 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.

Howdy, Stranger!

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

Categories

In this Discussion