summations-js
Library to enumerate all natural number lists with a target sum.
Package Installation and Usage
The package is available on npm:
npm install summations
The library can be imported in the usual ways:
var summations = ;
The library also supports standalone usage in browsers:
Examples
It is possible to enumerate all possible lists of natural numbers of a given length that add up to a target sum.
var results = summations;
Given the object above, we can query it for each value
> results 1 1 0 0 1 1 1 0 1 2 0 0 0 2 0 0 0 2
Testing
Unit tests are included in test/test.js
. They can be run using Mocha:
npm test