0.1.1 • Published 8 years ago

pascals-triangle v0.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

pascal's triangle

Get a triangular array of the binomial coefficients given a certain number of rows.

npm version Build status Test coverage

Install

npm install --save pascals-triangle

Usage

var triangle = require('pascals-triangle');

triangle(0); // [ [ 1 ] ]
triangle(1); // [ [ 1 ], [ 1, 1 ] ]
triangle(2); // [ [ 1 ], [ 1, 1 ], [ 1, 2, 1 ] ]

API

triangle(rows)

Returns a matrix (array of arrays) 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