PREP01 Editorial

Problem Explanation

In this problem we are provided with an integer N and we have to print the N^{th} line of Pascals triangle

Observation: We can observe that the {R_{th}} character has the value of {{}^{N}\!C_{R}} , which can be calculated from the previous value from the formula {{}^{N}\!C_{R}= {}^{N}\!C_{R-1} \cdot {(N-R+1) \over R}}

Approach: For each line an array is created with one element 1 which will be the first element in every line. Then using the above formula the next element is calculated and pushed into the array.