Java program to generate pattern of Equilateral triangle or full pyramid using the number and for loop


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

Equilateral triangle or full pyramid using the number and for loop

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