JSPM

permjs

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q5359F
  • License MIT

A library providing mathematical permutation, combination, and factorials.

Package Exports

  • permjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (permjs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

permjs

A library providing mathematical permutation, combination, and factorial operations.

Installation

Using npm:

npm install --save permjs

Usage

Permutation

Purpose

Finds the possible orders of n objects taken r at a time.

Mathmatical formula

nPr = n!/(n - r)!

Implementation

var permjs = require('permjs');

permjs.permutation(5, 2); // 5 nPr 2 => 20

Combination

Purpose

Finds the possible sets (without regard to order) of n objects taken r at a time.

Mathematical Formula

nCr = n!/(n - r)!r!

Implementation

var permjs = require('permjs');

permjs.combination(5, 2); // 5 nCr 2 => 10

Factorial

Purpose

Finds a number multipled by all integers smaller than it, down to 1. For example,

5! = 5 * 4 * 3 * 2 * 1 = 120

Mathematical Formula

n! = n * (n - 1) * (n - 2) ... * 1

Implementation

var permjs = require('permjs');

permjs.factorial(5); // 5! => 120

Pascal's Triangle

Purpose

Gives the binomial coefficients of the binomial power (a + b)^n

Mathematical Formula

Takes the following form:

row[0]:          1
row[1]:         1 1
row[2]:        1 2 1
row[3]:       1 3 3 1
row[4]:      1 4 6 4 1
row[5]:    1 5 10 10 5 1

...etc

Implementation

var permjs = require('permjs');

permjs.pascal(5); // row[5] => [1, 5, 10, 10, 5, 1]