n <- 5; P <- pascal_triangle(n)
for (i in 1:(n+1)) {
cat(P[i, 1:i], '\n')
}
## 1
## 1 1
## 1 2 1
## 1 3 3 1
## 1 4 6 4 1
## 1 5 10 10 5 1
if (FALSE) {
P <- pascal_triangle(50)
max(P[51, ])
## [1] 126410606437752
}
Run the code above in your browser using DataLab