Java Program to Print Square of Left Decrement Numbers Pattern

Write a Java program to print square of left decrement numbers pattern using for loop.

package Shapes3;

import java.util.Scanner;

public class SquareLeftDecNum1 {

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

This Java program displays the square pattern of decrement numbers from left hand side using a while loop.

package Shapes3;

import java.util.Scanner;

public class SquareLeftDecNum2 {

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