kingBook

导航

组合数

https://baike.baidu.com/item/组合数/2153250?fr=aladdin
\(C_n^0=1\)=\(C(n,0)\)=\(\tbinom{n}{0}\)=\(1\)
\(C_n^m\)=\(C(n,m)\)=\(\tbinom{n}{m}\)=\(\frac{n!}{m!(n-m)!}\)

\(\sum_{i=0}^n \tbinom{n}{i}\) 程序代码示例:

function test(n,m){
	let nf=1; for(let i=1;i<=n;i++)nf*=i;
	
	let mf=1; for(let i=1;i<=m;i++)mf*=i;
	
	let nsubm_f=1; for(let i=1;i<=n-m;i++)nsubm_f*=i;
	
	return nf/(mf*nsubm_f);
}

const n=10
for(var i=0;i<=n;i++){
	console.log(test(n,i));
}
/*
> 1
> 10
> 45
> 120
> 210
> 252
> 210
> 120
> 45
> 10
> 1
*/

posted on 2020-08-23 22:34  kingBook  阅读(69)  评论(0编辑  收藏  举报