Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Get the next partition of an integer in reverse lexicographic order
ResourceFunction["NextIntegerPartition"][p] gives the integer partition following p in reverse lexicographic order. |
The partition of an integer following the given one in the reverse lexicographic order:
In[1]:= | ![]() |
Out[1]= | ![]() |
NextIntegerPartition[p] gives the successor to the integer partition p in the list returned by IntegerPartitions:
In[2]:= | ![]() |
Out[2]= | ![]() |
In[3]:= | ![]() |
Out[3]= | ![]() |
Applying NextIntegerPartition to a partition of all ones loops back to the singleton partition:
In[4]:= | ![]() |
Out[4]= | ![]() |
The integer partition must be a list of non-increasing positive integers:
In[5]:= | ![]() |
Out[5]= | ![]() |
As the input fails to meet the requirement, NextIntegerPartition returns unevaluated:
In[6]:= | ![]() |
Out[6]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License