row 1 | 1
row 2 | 1 1
row 3 | 1 2 1
row 4 | 1 3 3 1
row 5 | 1 4 6 4 1
I recently made a computer program that involved Pascal's Triangles.
However I got obsessed with optimizing it.
I know there is a way to get Nth row / Xth element of the triangle. However any formulas I tried (including from math stack exchange) did not worked.
What I want is for example to have 5th row, 2nd element and result to be 4
.
Because most of other similar answers did not really work, will be glad, if you give me the answer as a function in some programming language.
Let suppose we have function long factorial(long x)
already done.
Thanks.
References that does not work: