A library providing mathematical permutation, combination, and factorial operations.
Using npm:
npm install --save permjs
Finds the possible orders of n objects taken r at a time.
nPr = n!/(n - r)!
const { permutation } = require('permjs');
permutation(5, 2); // 5 nPr 2 => 20
Finds the possible sets (without regard to order) of n objects taken r at a time.
nCr = n!/(n - r)!r!
const { combination } = require('permjs');
combination(5, 2); // 5 nCr 2 => 10
Finds a number multipled by all integers smaller than it, down to 1. For example,
5! = 5 * 4 * 3 * 2 * 1 = 120
n! = n * (n - 1) * (n - 2) ... * 1
const { factorial } = require('permjs');
factorial(5); // 5! => 120
Gives the binomial coefficients of the binomial power (a + b)^n
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
const { pascal } = require('permjs');
pascal(5); // row[5] => [1, 5, 10, 10, 5, 1]