New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

permjs

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

permjs

A library providing mathematical permutation, combination, and factorials.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

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]

Keywords

mathematics

FAQs

Package last updated on 04 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts