Java Program to Print Square of Right Decrement Numbers Pattern

Write a Java program to print the square of the right decremented numbers pattern using for loop.

```package Shapes4;

import java.util.Scanner;

public class SquareRightDecNum1 {

private static Scanner sc;

public static void main(String[] args) {
sc = new Scanner(System.in);

System.out.print("Enter Square Right Decrement Numbers Rows = ");
int rows = sc.nextInt();

System.out.println("The Square of Right Decrement Numbers Pattern");

for (int i = rows; i >= 1; i-- )
{
for (int j = rows; j >= i; j-- )
{
System.out.print(j + " ");
}
for(int k = rows - i + 1; k < rows; k++)
{
System.out.print(i + " ");
}
System.out.println();
}
}
}```

This Java program prints the square pattern of the right decremented numbers using a while loop.

```package Shapes4;

import java.util.Scanner;

public class SquareRightDecNum2 {

private static Scanner sc;

public static void main(String[] args) {
sc = new Scanner(System.in);

System.out.print("Enter Square Right Decrement Numbers Rows = ");
int rows = sc.nextInt();

System.out.println("The Square of Right Decrement Numbers Pattern");
int i, j, k;
i = rows;

while(i >= 1)
{
j = rows;
while(j >= i)
{
System.out.print(j + " ");
j--;
}
k = rows - i + 1;
while(k < rows)
{
System.out.print(i + " ");
k++;
}
System.out.println();
i--;
}
}
}```
``````Enter Square Right Decrement Numbers Rows = 8
The Square of Right Decrement Numbers Pattern
8 8 8 8 8 8 8 8
8 7 7 7 7 7 7 7
8 7 6 6 6 6 6 6
8 7 6 5 5 5 5 5
8 7 6 5 4 4 4 4
8 7 6 5 4 3 3 3
8 7 6 5 4 3 2 2
8 7 6 5 4 3 2 1 ``````