I need another simpler approach to solve this problem if possible

I want Pascal Triangle(Pattern3) Another approach to solve the problem more easily i used

import java.util.Scanner;

public class Main {
public static void main(String[] args) {
int n;
Scanner s1 = new Scanner(System.in);
n=s1.nextInt();
int[][] pascal = new int[n][n];

    // Fill in the first row with 1
    for (int i = 0; i < n; i++) {
        pascal[0][i] = 1;
    }
    System.out.println(pascal[0][0] + "\t");

    // Fill in the rest of the triangle
    for (int i = 1; i < n; i++) {
        for (int j = 0; j <= i; j++) {
            if (j == 0 || j == i) {
                pascal[i][j] = 1;
            } else {
                pascal[i][j] = pascal[i - 1][j - 1] + pascal[i - 1][j];
            }
            System.out.print(pascal[i][j] + "\t");
        }
        System.out.println();
    }
}

}

this code but it is seeeming complex logic Is there any other approach?

@budhirajarahul25 Pascal’s triangle is the triangular array of the binomial coefficients.The number of entries in a given line is equal to the line number.Every entry in the line is the value of a binomial coefficient. The value of ith entry in the number line is C(line,i)(i.e apply mathematical combination formula ).
Where C(line,i)=line!/((line-i)!*i!).

Given pattern can be formed using 3 approches:
1.A simple method is to run two loops and calculate the value of binomial coefficient in inner loop. Complexity: O(N3).
2.O(N2) time and O(n2) space complexity.In this method store the previously generated values in 2-D array. Use these values to generate value in a line.
3.O(N2) time and O(1) space complexity. In this method calculate C(line,i) using C(line,i-1). It can be calculated in O(1) time as follows:

C(line,i-1)=line!/((line-i+1)!*(i-1)!)
C(line,i)=line!/((line-i)!i!)
C(line,i)=C(line,i-1)
(line-i+1)/i.
Code:

import java.util.Scanner;
public class Main {

public static void main(String[] args) {
    Scanner scn=new Scanner(System.in);

    int n=scn.nextInt(),i,j;
   // work for each row
    for(i=1;i<=n;i++){

        int num=1;   // starting number

       // work for values
        for(j=1;j<=i;j++){

            if(j==1)
                System.out.print(j+"\t");
            else
            {
                num=num*(i-j+1)/(j-1);     // updating number
                System.out.print(num+"\t");
            }
        }
        System.out.print("\n");
    }

   }

}

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.