pyramid of numbers

how do i get one to come out like this as an upside down pyramid
12345678987654321
234567898765432
3456789876543
45678987654
567898765
6789876
78987
898
9

Comments

  • : how do i get one to come out like this as an upside down pyramid
    : 12345678987654321
    : 234567898765432
    : 3456789876543
    : 45678987654
    : 567898765
    : 6789876
    : 78987
    : 898
    : 9
    :

    you have posted this in the month of Sep.
    I think u might have got the answer by now...
    but anyways.. below is the code.

    class pyra
    {
    public static void main(String[] args){


    for(int i = 1; i < 10; i++)
    {


    for(int k = i; k < 10; k++)
    System.out.print(k);

    for(int l = 8; l >= i; l--)
    System.out.print(l);

    System.out.println("");
    }
    }
    }

    o/p:

    12345678987654321
    234567898765432
    3456789876543
    45678987654
    567898765
    6789876
    78987
    898
    9

    ------------------------------------------------------------------

    class pyra1
    {
    public static void main(String[] args){


    for(int i = 1; i < 10; i++)
    {
    for(int j = 1; j < i; j++)
    System.out.print("_");

    for(int k = i; k < 10; k++)
    System.out.print(k);

    for(int l = 8; l >= i; l--)
    System.out.print(l);

    System.out.println("");
    }
    }
    }


    o/p:

    12345678987654321
    _234567898765432
    __3456789876543
    ___45678987654
    ____567898765
    _____6789876
    ______78987
    _______898
    ________9

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