pascal's triangle
Get a triangular array of the binomial coefficients given a certain number of rows.
Install
npm install --save pascals-triangle
Usage
var triangle = ; ; // [ [ 1 ] ]; // [ [ 1 ], [ 1, 1 ] ]; // [ [ 1 ], [ 1, 1 ], [ 1, 2, 1 ] ]
API
triangle(rows)
Returns a matrix (array
of array
s) containing the values of the rows in order from top to bottom.
rows
Type: number
The number of rows or iterations to produce. It's a zero-based index, so if you want the first level you'd pass in 0
.
License
MIT © Alejandro Beltrán