



1
1 1
1 2 1
1 3 3 1
Here for the third row, you will see that the second element is the summation of the above two-row elements i.e. 2=1+1, and similarly for row three 3 = 1+2 and 3 = 1+2.
The first line of input contains an integer ‘T’ denoting the number of test cases.
The first line of each test case contains a single integer N denoting the row till which you have to print the pascal’s triangle.
For each test case, return the 2-D array/list containing the pascal’s triangle till the row N.
You do not need to print anything; it has already been taken care of. Just implement the given function.
1 <= T <= 40
1 <= N <= 50
Time Limit: 1 sec
The idea is to use recursion to get the value of the coefficients we will create a helper function CALPASCAL which will take row and entry as its input parameters and we call this function in the main function of PRINTPASCAL.
The idea is to use the definition of pascal’s triangle that its coefficients and are summation of adjacent elements in preceding rows. so in this way we can store the elements in a matrix and for further generation of values in it we can check the preceding elements and update the value.
The idea is to use the property of pascal’s triangle that its coefficients and are nothing but the binomial coefficients so we will calculate binomial coefficients of each line and at each index and print them, the coefficient value at every index is nCr where n is equal to the current row number and r is the rth entry in the row n and its value is FACT(n)/(FACT(n-r)*FACT(r)) where FACT(X) is the factorial of the number X but in this approach, we will use maths to derive the relation between Eth entry ‘RCE’ and (E-1)th entry RC(E-1)