Wolfram Research

Function Repository Resource:

IntegerPartitionQ

Source Notebook

Check whether the argument is a weakly decreasing list of positive integers

Contributed by: Wolfram Staff

ResourceFunction["IntegerPartitionQ"][x]

checks whether x is a weakly decreasing list of positive integers.

Details and Options

An integer partition is a multiset of positive integers and so not ordered. Therefore, any order can be used to represent it. Typically, the order chosen is weakly decreasing, as here; some people choose weakly increasing.

Examples

Basic Examples

Here are the 5 integer partitions of 4:

In[1]:=
IntegerPartitions[4]
Out[1]=

They all pass the test for being an integer partition:

In[2]:=
ResourceFunction["IntegerPartitionQ"] /@ IntegerPartitions[4]
Out[2]=

The parts all have to be integers:

In[3]:=
ResourceFunction["IntegerPartitionQ"][{3., 3, 1}]
Out[3]=

The parts have to be positive:

In[4]:=
ResourceFunction["IntegerPartitionQ"][{2, 1, 0}]
Out[4]=

The parts have to be in weakly decreasing order:

In[5]:=
ResourceFunction["IntegerPartitionQ"][{3, 1, 2}]
Out[5]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Resource History

License Information