js-combinations

1.0.1 • Public • Published

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

Package Sidebar

Install

npm i js-combinations

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • robin-front