triangle pattern ( icreasing,decreasing )

PHOTO EMBED

Sun Mar 27 2022 12:58:53 GMT+0000 (Coordinated Universal Time)

Saved by @zapohanec #java

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        pattern(5);

    }
    static void pattern(int n) {
        for (int row = 0; row <2*n ; row++) {
            int totalColsInRow =row>n? 2*n-row-1:row;
            for (int col = 0; col < totalColsInRow; col++) {
                System.out.print("* ");

            }
            System.out.println();
        }

    }
}
content_copyCOPY