整数 n をより小さい整数に分割する可能なすべての方法のリストを返す.
IntegerPartitions[n,k]
最高で k 個の整数に分割する.
IntegerPartitions[n,{k}]
厳密に k 個の整数に分割する.
IntegerPartitions[n,{kmin,kmax}]
kmin 個から kmax個までの整数に分割する.
IntegerPartitions[n,kspec,{s1,s2,…}]
siだけを含む部分を与える.
IntegerPartitions[n,kspec,sspec,m]
結果を最初の m 通りに限定する.
IntegerPartitions
整数 n をより小さい整数に分割する可能なすべての方法のリストを返す.
IntegerPartitions[n,k]
最高で k 個の整数に分割する.
IntegerPartitions[n,{k}]
厳密に k 個の整数に分割する.
IntegerPartitions[n,{kmin,kmax}]
kmin 個から kmax個までの整数に分割する.
IntegerPartitions[n,kspec,{s1,s2,…}]
siだけを含む部分を与える.
IntegerPartitions[n,kspec,sspec,m]
結果を最初の m 通りに限定する.
詳細
- IntegerPartitionsの結果は一般に辞書的順序の逆の順序で与えられる.
- Length[IntegerPartitions[n]]はPartitionsP[n]である.
- IntegerPartitions[n]はIntegerPartitions[n,All]と等価である.
- IntegerPartitions[n,{kmin,kmax,dk}]は kmin, kmin+dk, … の整数に分割する.
- n および siは有理数でもよく,負の数でもよい.
- 分割リストでは,はじめの方の siを含む部分が最後に与えられる.
- IntegerPartitions[n,kspec,sspec,-m]は結果を最後の m 通りに限定する.
- IntegerPartitions[n,kspec,sspec,m]では,Allの kspec は{0,Infinity}に相当する.Allの sspec はRange[n]に相当する.Allの m はInfinityに相当する.
例題
すべて開く すべて閉じる例 (3)
スコープ (6)
IntegerPartitions[8]IntegerPartitions[8, 3]IntegerPartitions[8, {1, 3}]IntegerPartitions[8, {3}]IntegerPartitions[8, {2, Infinity, 2}]Length /@ %IntegerPartitions[8, All, {1, 2, 5}]IntegerPartitions[15, All, All, 10]IntegerPartitions[15, All, All, -3]一般化と拡張 (2)
アプリケーション (2)
10個以下の標準的な硬貨を使って156セントにする方法を求める:
IntegerPartitions[156, 10, {1, 5, 10, 25}]IntegerPartitions[50, All, {6, 9, 20}]50までの数の「マックナゲット分割」がそれぞれ何通りあるかを求める:
Table[Length[IntegerPartitions[i, All, {6, 9, 20}]], {i, 50}]Position[%, 0]//Flatten最後の場合は厳密にフロベニウス(Frobenius)数に対応している:
FrobeniusNumber[{6, 9, 20}]特性と関係 (4)
IntegerPartitions[4]Total /@ %IntegerPartitions[n]の長さはPartitionsP[n]である:
Length[IntegerPartitions[10]]PartitionsP[10]IntegerPartitionsは結果をSort順ではなく辞書的な順とは逆の順序で与える:
IntegerPartitions[5]Sort[%]10より小さい整数の場合は,文字列に変換することでIntegerPartitions順を生成する:
ReverseSort[ToString /@ IntegerPartitions[5]]FrobeniusSolveはIntegerPartitionsの係数リストを与える:
FrobeniusSolve[{6, 9, 20}, 24]IntegerPartitions[24, All, {6, 9, 20}]考えられる問題 (3)
IntegerPartitionsでは分割の無限リストは与えられない:
IntegerPartitions[5, All, {1, -1}]IntegerPartitions[5, 10, {1, -1}]IntegerPartitions[1 / 2]IntegerPartitions[1 / 2, All, {1 / 6, 1 / 3}]4番目の引数によって要求される要素のすべては存在しないときは,警告メッセージが出される:
IntegerPartitions[3, All, All, 7]メッセージを出さないようにするのにはOffを使う:
Off[IntegerPartitions::take]IntegerPartitions[3, All, All, 7]テクニカルノート
関連リンク
テキスト
Wolfram Research (2007), IntegerPartitions, Wolfram言語関数, https://reference.wolfram.com/language/ref/IntegerPartitions.html (2008年に更新).
CMS
Wolfram Language. 2007. "IntegerPartitions." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2008. https://reference.wolfram.com/language/ref/IntegerPartitions.html.
APA
Wolfram Language. (2007). IntegerPartitions. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/IntegerPartitions.html
BibTeX
@misc{reference.wolfram_2026_integerpartitions, author="Wolfram Research", title="{IntegerPartitions}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/IntegerPartitions.html}", note=[Accessed: 25-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_integerpartitions, organization={Wolfram Research}, title={IntegerPartitions}, year={2008}, url={https://reference.wolfram.com/language/ref/IntegerPartitions.html}, note=[Accessed: 25-November-2026]}