Inverted Half Pyramid with Numbers Pattern Java Programming Code

Inverted Half Pyramid with Numbers Output Screenshot



Inverted Half Pyramid with Numbers Pattern Simple Java Code

public class Inverted_Half_Pyramid_with_Numbers {
    public static void main(String[] args) {
        IHPN(9);

    }

    public static void IHPN(int n) {
        for (int i = 1; i <= n; i++) {
            // inner - numbers
            for (int j = 1; j <= n - i + 1; j++) {
                System.out.print(j);
                // System.out.print(j + " ");
            }
            System.out.println();
        }
    }
}

No comments:

Post a Comment

Max Sub Array Sum: Kadane's Algorithm

Code of: Max Sub Array Sum: Kadane's Algorithm. public class MaxSubArraySumKadanesALgorithm {     public static void Kadane ( int ...