Java Program to Print Left Arrow Numbers Pattern

Write a Java program to print left arrow numbers pattern using for loop.

package Shapes3;
import java.util.Scanner;

public class LeftArrorwNum1 {

	private static Scanner sc;
	
	public static void main(String[] args) {
		
		sc = new Scanner(System.in);	
		
		int i, j;
		
		System.out.print("Enter Left Arrow Number Pattern Rows = ");
		int rows = sc.nextInt();
		
		System.out.println("Printing Left Arrow Numbers Pattern");		
		
		for (i = rows; i >= 1; i-- ) 
		{
			for (j = i; j >= 1; j--) 	
			{
				System.out.print(j+ " ");
			}
			System.out.println();
		}
		
		for (i = 2; i <= rows; i++ ) 
		{
			for (j = i; j >= 1; j-- ) 	
			{
				System.out.print(j+ " ");
			}
			System.out.println();
		}
	}
}
Java Program to Print Left Arrow Numbers Pattern

This program prints the left arrow of numbers pattern using while loop.

package Shapes3;

import java.util.Scanner;

public class LeftArrorwNum2 {

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

This example uses the do while loop to display the left arrow pattern of numbers.

package Shapes3;

import java.util.Scanner;

public class LeftArrorwNum3 {

	private static Scanner sc;
	
	public static void main(String[] args) {
		
		sc = new Scanner(System.in);	
		
		int i, j;
		
		System.out.print("Enter Left Arrow Number Pattern Rows = ");
		int rows = sc.nextInt();
		
		System.out.println("Printing Left Arrow Numbers Pattern");		
		i = rows;
		
		do
		{
			j = i;
			do	
			{
				System.out.print(j+ " ");

			} while(--j >= 1);
			System.out.println();

		} while(--i >= 1 );
		
		i = 2;
		do
		{
			j = i;
			do 	
			{
				System.out.print(j+ " ");

			} while(--j >= 1 );
			System.out.println();

		} while(++i <= rows );
	}
}
Enter Left Arrow Number Pattern Rows = 13
Printing Left Arrow Numbers Pattern
13 12 11 10 9 8 7 6 5 4 3 2 1 
12 11 10 9 8 7 6 5 4 3 2 1 
11 10 9 8 7 6 5 4 3 2 1 
10 9 8 7 6 5 4 3 2 1 
9 8 7 6 5 4 3 2 1 
8 7 6 5 4 3 2 1 
7 6 5 4 3 2 1 
6 5 4 3 2 1 
5 4 3 2 1 
4 3 2 1 
3 2 1 
2 1 
1 
2 1 
3 2 1 
4 3 2 1 
5 4 3 2 1 
6 5 4 3 2 1 
7 6 5 4 3 2 1 
8 7 6 5 4 3 2 1 
9 8 7 6 5 4 3 2 1 
10 9 8 7 6 5 4 3 2 1 
11 10 9 8 7 6 5 4 3 2 1 
12 11 10 9 8 7 6 5 4 3 2 1 
13 12 11 10 9 8 7 6 5 4 3 2 1 

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.