pascals-triangle-ts
TypeScript icon, indicating that this package has built-in type declarations

0.3.3 • Public • Published

pascals-triangle-ts

A package to generate pascals triangle in multiple ways

npm version

Install

npm install --save pascals-triangle-ts

Usages

import {CreateAsNumbers, CreateAsBigInt} from 'pascals-triangle-ts';

CreateAsNumbers(1); // [ [ 1 ] ]
CreateAsNumbers(2); // [ [ 1 ], [ 1, 1 ] ]
CreateAsNumbers(3); // [ [ 1 ], [ 1, 1 ], [ 1, 2, 1] ]

CreateAsBigInt(1); // [ [ '1' ] ]
CreateAsBigInt(2); // [ [ '1' ], [ '1', '1' ] ]
CreateAsBigInt(3); // [ [ '1' ], [ '1', '1' ], [ '1', '2', '1' ] ]

API

CreateAsNumbers(rows: number = 0): number[][]

Return a maxtrix (array of array's) containing the values as integers of the rows in order from top to bottom.

rows

Type: number Default: 0

  • Zero-based -- if you want to generate the first level you should pass in 0
  • Greater than or equal to 0
  • Less than 57 -- Row 57 and rows after will calculate an integer values greater than safe maximum integer. It is not wise to calculate futher with that value -- If the required rows is greater than or equal to 57, you should use CreateAsBigInt

CreateAsBigInt = (rows: number = 0): bigint[][]

Return a maxtrix (array of array's) containing the values as bigint's of the rows in order from top to bottom.

rows

Type: number Default: 0

  • Zero-based -- if you want to generate the first level you should pass in 0
  • Greater than or equal to 0

Test

Clone repo, open prompt in repo directory and run following commands:

npm install
npm test

License

MIT © Remco Vorthoren

Package Sidebar

Install

npm i pascals-triangle-ts

Weekly Downloads

0

Version

0.3.3

License

MIT

Unpacked Size

25 kB

Total Files

33

Last publish

Collaborators

  • talkon