Slip No 5 Q A

Q.Write a java program to display following pattern: [15 M]
5
4 5
3 4 5
2 3 4 5
1 2 3 4 5

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

        for(int i = 5; i >= 1; i--) {
            for(int j = i; j <= 5; j++) {
                System.out.print(j + " ");
            }
            System.out.println();
        }
    }
}
Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top