Generate Pascal's Triangle
stm_pascal.Rd
stm_pascal()
generates Pascal's Triangle up to the n
-th row
and returns the triangle matrix along with the coefficients in the
last row.
Value
A list containing:
- y
A matrix representing Pascal's Triangle.
- coefs
A vector of the coefficients in the last row of the triangle.
Examples
stm_pascal(3)
#> $y
#> [,1] [,2] [,3]
#> [1,] 1 1 1
#> [2,] 1 2 3
#> [3,] 1 3 6
#>
#> $coefs
#> [1] 1 3 6 3 1
#>
stm_pascal(5)
#> $y
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 1 1 1 1 1
#> [2,] 1 2 3 4 5
#> [3,] 1 3 6 10 15
#> [4,] 1 4 10 20 35
#> [5,] 1 5 15 35 70
#>
#> $coefs
#> [1] 1 5 15 35 70 35 15 5 1
#>