Skip to content

Robin-front/js-combinations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

n choose k for javascript,find the amount of possible combinations of n elements

Topics

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published