Java Program to Print Downward Triangle Mirrored Numbers Pattern

Write a Java program to print downward triangle mirrored numbers pattern using for loop.

package Shapes3;

import java.util.Scanner;

public class DownwardTriMirrNum1 {

	private static Scanner sc;
	
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		System.out.print("Enter Downward Traingle Mirrored Numbers Rows = ");
		int rows = sc.nextInt();
		
		System.out.println("Downward Traingle of Mirrored Numbers Pattern");
		
		for (int i = 1; i <= rows; i++ ) 
		{
			for (int j = i; j <= rows; j++ ) 
			{
				System.out.print(j + " ");
			}
			for(int k = rows - 1; k >= i; k--) 
			{
				System.out.print(k + " ");
			}
			System.out.println();
		}
	}
}
Java Program to Print Downward Triangle Mirrored Numbers Pattern

This Java example prints the downward triangle pattern of mirrored numbers using while loop.

package Shapes3;

import java.util.Scanner;

public class DownwardTriMirrNum2 {

	private static Scanner sc;
	
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		System.out.print("Enter Downward Traingle Mirrored Numbers Rows = ");
		int rows = sc.nextInt();
		
		System.out.println("Downward Traingle of Mirrored Numbers Pattern");
		int j, k, i = 1; 
		
		while(i <= rows) 
		{
			j = i;
			while(j <= rows) 
			{
				System.out.print(j + " ");
				j++;
			}
			
			k = rows - 1;
			while(k >= i) 
			{
				System.out.print(k + " ");
				k--;
			}
			
			System.out.println();
			i++;
		}
	}
}
Enter Downward Traingle Mirrored Numbers Rows = 9
Downward Traingle of Mirrored Numbers Pattern
1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1 
2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 
3 4 5 6 7 8 9 8 7 6 5 4 3 
4 5 6 7 8 9 8 7 6 5 4 
5 6 7 8 9 8 7 6 5 
6 7 8 9 8 7 6 
7 8 9 8 7 
8 9 8 
9