combinat::partitions
--
n-th partitions numbercombinat::partitions
(n)
returns the number
of partitions of the nonnegative integer n
.
combinat::partitions(n)
n |
- | a nonnegative integer |
The number of partitions as a positive integer.
n
is the number of representations of n
as n = n_1 +
... + n_k, n_i >= 1, i=1..k. By definition
combinat::partitions
(0)
is 1.n
Euler's pentagonal formula is used to
compute combinat::partitions
(n)
.
p(n) + sum((-1)^k*(p(n-w(k)) + p(n-w(-k))), k = 1..infinity) = 0, where w(k) = (3*k^2 + k)/2
For large n
the Hardy-Ramanujan-Rademacher formula is
used.
We can write 3 in 3 different ways as a sum of nonnegative integers. They are 3=1+1+1=1+2=3.
>> combinat::partitions(3)
3
The number of partitions of n grows very rapidly for larger n.
>> combinat::partitions(111)
679903203
A negative number cannot be written as a sum of positive integers.
>> combinat::partitions(-3)
Error: Argument must be a nonnegative integer [combinat::parti\ tions]
G. Andrews, The Theory of Partitions, Addison-Wesley, 1976