Java program to generate left angled triangle or left half pyramid using number and for loop


        1
      1 2
    1 2 3
  1 2 3 4
1 2 3 4 5

Left-angled triangle or Left half pyramid using the number and for loop

Program
import java.util.*; public class Main { public static void main(String[] args) { for (int i = 1; i <= 5; i++) { for(int k = 5; k >= i; k--) { System.out.print(" "); } for (int j = 1; j <= i; j++) { System.out.print(j); } System.out.println(); } } }
Input
Output

Similar Program

# Program Language
1 Java
2 Java
3 Java
4 Java
5 Java
6 Java
7 Java
8 Java
9 Java
10 Java
11 Java
12 Java
13 Java
14 Java
15 Java
16 Java
17 Java
18 Java
19 Java
20 Java
# Program Language