Program to print reverse order triangle number patterns

Here we will discuss to reverse order triangle number patterns. A number pattern is a series of numbers that generate a certain pattern or geometrical shape like a triangle.

  • Create the object of Scanner class.
  • Declare a variable numberOfRow to store the number of rows.
  • Use two for loops to print the reverse order triangle number patterns
  • Use the outer for loop to iterate through rows from 1 to numberOfRow.
  • Use the inner for loop to iterate through columns from numberOfRow. to i.
  • Print the number patterns through j variable where the condition satisfies.
  • Display the result.
				
					import java.util.Scanner;

public class ReverseTriangleNumber {

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

		}
	}
}
				
			

Output :-
enter the number of rows:
10
10 9 8 7 6 5 4 3 2 1
10 9 8 7 6 5 4 3 2
10 9 8 7 6 5 4 3
10 9 8 7 6 5 4
10 9 8 7 6 5
10 9 8 7 6
10 9 8 7
10 9 8
10 9
10