public static void printPascalTriangle(int n) {
        int[][] grid = new int[n][n];
        // first loop for number of rows
        for( int i=0; i< grid.length; i++) {
            //second loop for number of elements
            for( int j = 0; j < i+1; j++) {
                // i-1 and j-1 are greater or equals to zero
                if(i-1 >= 0 && j-1 >= 0) {
                    //apply pasacl'a formulae
                   grid[i][j] = grid[i-1][j] + grid[i-1][j-1];
                } else {
                    // else assign it to zero
                    grid[i][j] = 1;
                }

            }
        }

        for( int i = 0; i< n; i++) {
            for (int j = 0; j< n; j++) {
                if(grid[i][j]!=0) {
                    System.out.print(" " + grid[i][j] + " ");
                }
            }
            System.out.println();
        }

    }