How to generate inverted right triangle of numbers in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {

    public static void main(String[] args) {

        for (int i = 7; i > 0; i--) {
            for (int j = 0; j < i; j++) {
                System.out.print(j + 1);
            }
            System.out.println("");
        }
    }
}
 
/*

run:

1234567
123456
12345
1234
123
12
1

*/

 



answered Oct 11, 2016 by avibootz

Related questions

1 answer 175 views
1 answer 160 views
1 answer 162 views
1 answer 147 views
...