Learn R Programming

partitions (version 1.1-2)

P: Number of partitions of an integer

Description

Given an integer, P() returns the number of additive partitions, Q() returns the number of unequal partitions, and R() returns the number of restricted partitions.

Usage

P(n, give = FALSE)
Q(n, give = FALSE)
R(m, n, include.zero=FALSE)

Arguments

n
Integer whose partition number is desired
m
In function R(), the order of the decomposition
give
Boolean, with default FALSE meaning to return just P(n) or Q(n) and TRUE meaning to return P(1:n) or Q(1:n) (this option takes no extra computation)
include.zero
In restrictedparts(), Boolean with default FALSE meaning to count only partitions of $n$ into exactly $m$ parts; and TRUE meaning to include partitions of $n$ into at most $m$ parts

Details

Functions P() and Q() use Euler's recursion formula. Function R() enumerates the partitions using Hindenburg's method (see Andrews) and counts them until the recursion bottoms out.

References

G. E. Andrews. The Theory of Partitions, Cambridge University Press, 1998.

Examples

Run this code
P(10,give=TRUE)
Q(10,give=TRUE)
R(10,20,include.zero=FALSE)
R(10,20,include.zero=TRUE)

Run the code above in your browser using DataLab