Print Number Pattern - 6 | Java Programs

Output:

Enter the number of rows: 8

8 7 6 5 4 3 2 1 
8 7 6 5 4 3 2 
8 7 6 5 4 3 
8 7 6 5 4 
8 7 6 5 
8 7 6 
8 7 
8

Click Here For Java Online Compiler

Solution:

import java.util.Scanner;

class NumberPattern6 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("Enter the number of rows: ");
        int base = scanner.nextInt();
        System.out.println();
        for (int j = 1; j <= base; j++) {
            for (int i = base; i >= j; i--) {
                System.out.print(i + " ");
            }
            System.out.println();
        }
    }
}
Share This :

Related Post



sentiment_satisfied Emoticon