トップページ > プログラミング研究室 > Ways!
Ways!
異なるn個の元 (element) からなる有限集合 (finite set) の中からr個を選ぶ順列 (permutation) や組み合わせ (combination) の総数 (number of ways) を計算します。
[ 戻る ]
場合の数の計算
項目 |
結果 |
組合せ |
|
重複組合せ |
|
順列 |
|
重複順列 |
|
円順列 |
|
数珠順列 |
|
完全順列 |
|
階乗 n! |
|
二重階乗n‼ |
|
中心二項係数 |
|
カタラン数 |
|
[ 戻る ]
使用方法
- nとr (n≥r≥0) に999以下の自然数 (natural number) を入力してから、[計算]ボタンをクリックします。
- 算出する項目の意味は次の通りです。
- 組合せ (combination) nCr
- 異なるn個の中からr個を重複なく選んだときの組合せの数。(x+y)nの展開におけるxn-ryrの係数である二項係数 (binomial coefficients) と同じ
- 重複組合せ (combination with repetition) nHr
- 異なるn個の中からr個を重複を許して選んだときの組合せの数
- 順列 (permutation) nPr
- 異なるn個の中からr個を重複なく選んで並べたときの場合の数
- 重複順列 (permutation with repetition) nΠr
- 異なるn個の中からr個を重複を許して並べたときの場合の数
- 円順列 (circular permutation) cir(n,r)
- 異なるn個の中からr個を重複なく選んで円形に並べたときの場合の数
- 数珠順列 (necklace problem) neck(n,r)
- 円順列のうち、裏返して一致するものを同じとみなしたときの場合の数
- 完全順列 (complete permutations)・攪乱順列 (derangement) Dn
- 1からnまでの自然数を要素とする順列において、i番目 (i≤n) がiでない順列
- 階乗 (factorial) n!
- 1からnまでの全ての自然数の積
- 二重階乗 (double factorial) n‼
- 1からnまでnと同じ偶奇性 (parity) を持つ自然数の積
- 中心二項係数 (central binomial coefficient) 2nCn
- パスカルの三角形 (Pascal's triangle) の奇数行の真ん中の値
- カタラン数 (Catalan number) cn
- 中心二項係数をn+1で除した値で、ノード (node) 数nの二分木 (binary tree) の総数、n-1段の階段状格子路の最短経路、凸n+2角形 (convex n+2 polygon) の三角形分割、n組の括弧付けなどの数え上げに登場する数
[ 戻る ]
利用上の注意
- Microsoft Edge、Internet Exploler 11、FireFox 45.0以降での動作を確認しています。
- その他のブラウザでの動作は保証いたしません。
- 計算結果が9007199254740991 (=253−1) より大きいときは指数表現の近似値になります。
- 計算結果が1.7976931348623157×10308 (≈21024) 以上のときは"Infinity"と表示します。
- 円順列ではn≥r>0、数珠順列ではn≥r≥3である必要があります。
- 完全順列、階乗、二重階乗、中心二項係数、カタラン数の計算ではrの値は使用しません。
- サポートは一切行いません。
- 気が向いたときに改良や修正をします。
[ 戻る ]
アルゴリズム
各値は次式で算出しています。
- 階乗
![n!](https://chart.googleapis.com/chart?cht=tx&chf=bg,s,e5fff700&chl=\[n!=\prod_{\scriptsize k=1}^{\scriptsize n}k=n\times(n-1)\times\cdots\times3\times2\times1\])
- 二重階乗
![n!!](https://chart.googleapis.com/chart?cht=tx&chf=bg,s,e5fff700&chl=\[n!!=\prod_{\scriptsize k=0}^{\scriptsize \lceil n/2\rceil-1}(n-2k)=\begin{cases}{n\times(n-2)\times\cdots\times4\times2(n:even)}\\{n\times(n-2)\times\cdots\times3\times1(n:odd)}\end{cases}\])
- 順列
![nPr](https://chart.googleapis.com/chart?cht=tx&chf=bg,s,e5fff700&chl=_nP_r=\frac{n!}{(n-r)!}=n\times(n-1)\times(n-2)\times\cdots\times(n-r%2b1))
- 組合せ
![nCr](https://chart.googleapis.com/chart?cht=tx&chf=bg,s,e5fff700&chl=_nC_r=\frac{_nP_r}{r!}=\frac{n!}{r!(n-r)!}=\frac{n}{1}\times\frac{n-1}{2}\times\cdots\times\frac{n-r%2b1}{r})
- 重複組合せ
![nHr](https://chart.googleapis.com/chart?cht=tx&chf=bg,s,e5fff700&chl=_nH_r=_{n%2b r-1}C_r=\frac{(n%2b r-1)!}{r!(n-1)!})
- 重複順列
![nΠr](https://chart.googleapis.com/chart?cht=tx&chf=bg,s,e5fff700&chl=_n\Pi_r=n^r=n\times n\times\cdots\times n)
- 円順列
![nPr/r](https://chart.googleapis.com/chart?cht=tx&chf=bg,s,e5fff700&chl=cir(n,r)=\frac{_nP_r}{r}=\frac{n\times(n-1)\times\cdots\times(n-r%2b1)}{r})
- 数珠順列
![nPr/2r](https://chart.googleapis.com/chart?cht=tx&chf=bg,s,e5fff700&chl=neck(n,r)=\frac{cir(n,r)}{2}=\frac{_nP_r}{2r}=\frac{n\times(n-1)\times\cdots\times(n-r%2b1)}{2r})
- 完全順列
![comp](https://chart.googleapis.com/chart?cht=tx&chf=bg,s,e5fff700&chl=\begin{cases}D_1=0,D_2=1\\D_n=(n-1)\times(D_{n-1}%2bD_{n-2})%26n\ge3\end{cases})
- 中心二項係数
![comp](https://chart.googleapis.com/chart?cht=tx&chf=bg,s,e5fff700&chl=_{2n}C_n=\frac{(2n)!}{(n!)^2})
- カタラン数
![comp](https://chart.googleapis.com/chart?cht=tx&chf=bg,s,e5fff700&chl=c_n=\frac{_{2n}C_n}{n%2b1}=\frac{(2n)!}{n!(n%2b1)!})
[ 戻る ]