Learn R Programming

rpartitions (version 0.1)

NrParts: Find the number of partitions for a given total Q and number of parts N.

Description

This function was recoded and modified from GAP source code: www.gap-system.org. Modifications for speed were based on the proposition that the number of partitions of Q having N parts is equal to the number of partitions of Q having N parts is equal to the number of partitions of Q - N, if N > Q/2 (for odd Q) or if N >= Q/2 (for even Q)

Usage

NrParts(Q, N = NULL, use_c = TRUE)

Arguments

Q
Total sum
N
Number of items to sum across, if not specified than all possible values are considered
use_c
logical, defaults to TRUE, the number of partitions is computed in c

Examples

Run this code
NrParts(100)
NrParts(100, 10)

Run the code above in your browser using DataLab