Answer:
Here is the JAVA program:
import java.util.Scanner; // to take input from user
public class PatternTwo{ //class name
public static void main(String args[]){ //start of main function
Scanner scan = new Scanner(System.in); // creates Scanner class object
System.out.print("Please enter a number: "); //prompts user to enter an int n for the number of rows
int n = scan.nextInt(); //reads and scans the value of n from user
int i, j; //declares two variables to iterate through i rows and j columns
for (i=1; i<=n; i++){ //outer loop for rows
for (j=2*(n-i); j>=1; j--){
//inner loop for space between numbers in pattern
System.out.print(" "); } //displays an empty space in the pattern
for (j = i; j >= 1; j--) { //inner loop for columns
System.out.print(j+" "); } //prints the value of j (prints numbers in reverse)
System.out.println(); } } } //prints a new line after printing each row
Explanation:
The program is explained with an example in the attached document.