## `combinat::partitions` -- n-th partitions number

#### Introduction

`combinat::partitions``(n)` returns the number of partitions of the nonnegative integer `n`.

#### Call(s)

`combinat::partitions(n)`

#### Parameters

`n` | - | a nonnegative integer

#### Returns

The number of partitions as a positive integer.

#### Details

- The number of partitions of the nonnegative 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.
- For small `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.

#### Example 1

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

#### Example 2

The number of partitions of n grows very rapidly for larger n.

    >> combinat::partitions(111)

                                     679903203

#### Example 3

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]

#### Further Documentation

G. Andrews, The Theory of Partitions, Addison-Wesley, 1976

#### Changes

- no changes

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000