Miscellaneous Toolkit - partint


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.