Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Get the next composition of an integer in canonical order
ResourceFunction["NextIntegerComposition"][l] gives the integer composition that follows l in canonical order. |
The composition of an integer following the given one:
| In[1]:= |
| Out[1]= |
NextIntegerComposition[l] gives the successor to l in the list returned by the resource function IntegerCompositions:
| In[2]:= |
| Out[2]= |
| In[3]:= |
| Out[3]= |
You can obtain this list by iteratively computing the next integer up to the length of such compositions, which for the integer n split into k parts is Binomial[n+k-1,n]:
| In[4]:= |
| Out[4]= |
This work is licensed under a Creative Commons Attribution 4.0 International License