- #1
ktoz
- 171
- 12
Hi
Is there a relatively easy way to calculate the number of partitions of a number given the maximum term and the count of terms?
A couple of examples:
25 has four partitions with five terms where each term is unique and the largest term is 8
{8,6,5,4,2}
{8,7,5,3,2}
{8,7,5,4,1}
{8,7,6,3,1}
10 has two partitions with 3 terms where each term is unique and the largest term is 5
{5,3,2}
{5,4,1}
For small numbers, it's pretty easy to write a filter that just iterates through all the possibilities selecting partitions with the chosen properties, but iteration becomes unfeasible as the number gets larger. Is there a way to directly calculate these values?
Thanks for any help/
Is there a relatively easy way to calculate the number of partitions of a number given the maximum term and the count of terms?
A couple of examples:
25 has four partitions with five terms where each term is unique and the largest term is 8
{8,6,5,4,2}
{8,7,5,3,2}
{8,7,5,4,1}
{8,7,6,3,1}
10 has two partitions with 3 terms where each term is unique and the largest term is 5
{5,3,2}
{5,4,1}
For small numbers, it's pretty easy to write a filter that just iterates through all the possibilities selecting partitions with the chosen properties, but iteration becomes unfeasible as the number gets larger. Is there a way to directly calculate these values?
Thanks for any help/