🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more
Socket
Book a DemoInstallSign in
Socket

js-combinations

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-combinations

n choose k for js

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

js-combinations 数学计算排列组合

Travis npm package Coveralls

calculate combinations of Math, find the amount of possible combinations of n elements

计算 n 个元素中,选出 k 个元素所有可能的组合数量

数学公式:

but, if k > n, return 0;

install

yarn add js-combinations
// or
npm install js-combinations --save

usage

import combinations from 'js-combinations';
const result = combinations(6, 4);
// =>  15

cache 关于缓存

use cache by default in factorial function for high performance, if you dont want to use cache, you can import combinationsWithoutCache, eg:

默认在阶乘函数中使用缓存,以提高重复计算的性能表现,但会减加少许内存。 如果不想使用缓存版本,可以 import 无缓存版本 :combinationsWithoutCache

import { combinationsWithoutCache } from 'js-combinations'
// ... what you want to do

Keywords

combinations

FAQs

Package last updated on 18 Jan 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