Loadable Function: p = partint(n)

Calculate all integer partitions. Argument n be a positive number. A partition is the sum decomposition of integers.

Example:

partint(4)

returns

ans =
 4  0  0  0
 2  1  0  0
 0  2  0  0
 1  0  1  0
 0  0  0  1

This means

Note:

partint(n) * [1:n]’ == n

Reference: Joerg Arndt: Algorithms for programmers (http://www.jjj.de), 2006.

See also: partcnt.

Demonstration 1

The following code

 p = partcnt([1, 5; 17 -5])

Produces the following output

p =

     1     7
   297   NaN

Demonstration 2

The following code

 p = partint(4)

Produces the following output

p =

   4   0   0   0
   2   1   0   0
   0   2   0   0
   1   0   1   0
   0   0   0   1

Package: miscellaneous