1.0.1 • Published 6 years ago

js-combinations v1.0.1

Weekly downloads
26
License
MIT
Repository
github
Last release
6 years ago

js-combinations 数学计算排列组合

Travis npm package Coveralls

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

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

数学公式: npm.io npm.io

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