Number of compositions

ncompositions(n, k = NULL, bigz = FALSE)

Arguments

n

an non-negative integer to be partitioned

k

number of parts

bigz

an logical to use gmp::bigz

See also

compositions for generating all compositions and icompositions for iterating compositions

Examples

# number of compositions of 10 ncompositions(10)
#> [1] 512
# number of compositions of 10 into 5 parts ncompositions(10, 5)
#> [1] 126
# integer overflow if (FALSE) ncompositions(160) ncompositions(160, bigz = TRUE)
#> Big Integer ('bigz') : #> [1] 730750818665451459101842416358141509827966271488
# zero sized compositions ncompositions(0)
#> [1] 1
ncompositions(5, 0)
#> [1] 0
ncompositions(5, 6)
#> [1] 0
ncompositions(0, 0)
#> [1] 1
ncompositions(0, 1)
#> [1] 0