Java Program to Print Right Triangle of Incremented Numbers

Write a Java program to print right triangle of incremented numbers pattern using for loop.

import java.util.Scanner;

public class RightTriIncrementedNum1 {
	
	private static Scanner sc;
	
	public static void main(String[] args) {
		
		sc = new Scanner(System.in);	
		
		System.out.print("Right Triangle of Incremented Numbers Rows = ");
		int rows = sc.nextInt();
		
		System.out.println("Right Triangle of Incremented Numbers Pattern");
		
		for (int i = 1 ; i <= rows; i++ ) 
		{
			for (int j = i ; j >= 1; j-- ) 	
			{
				System.out.printf("%d ", j);
			}
			System.out.println();
		}
	}
}
Java Program to Print Right Triangle of Incremented Numbers

This Java example displays the incremented numbers in right angled triangle pattern using a while loop.

import java.util.Scanner;

public class RightTriIncrementedNum2 {
	
	private static Scanner sc;
	
	public static void main(String[] args) {
		
		sc = new Scanner(System.in);	
		
		int i = 1, j; 
		
		System.out.print("Right Triangle of Incremented Numbers Rows = ");
		int rows = sc.nextInt();
		
		System.out.println("Right Triangle of Incremented Numbers Pattern");
		
		while (i <= rows ) 
		{
			j = i ;
			
			while( j >= 1 ) 	
			{
				System.out.printf("%d ", j);
				j--;
			}
			System.out.println();
			i++;
		}
	}
}
Right Triangle of Incremented Numbers Rows = 9
Right Triangle of Incremented Numbers Pattern
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 

Java program to print right angled triangle of incremented numbers pattern using do while loop.

import java.util.Scanner;

public class RightTriIncrementedNum3 {
	
	private static Scanner sc;
	
	public static void main(String[] args) {
		
		sc = new Scanner(System.in);	
		
		System.out.print("Right Triangle of Incremented Numbers Rows = ");
		int rows = sc.nextInt();
		
		System.out.println("Right Triangle of Incremented Numbers Pattern");
		int i = 1, j; 
		
		do
		{
			j = i ;
			
			do	
			{
				System.out.printf("%d ", j);
			} while(--j >= 1 );
			
			System.out.println();

		} while (++i <= rows );
	}
}
Right Triangle of Incremented Numbers Rows = 14
Right Triangle of Incremented Numbers Pattern
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 
14 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.