This function computes the Bell numbers, which is the summ of Stirling numbers of the second kind, \(S(n, k)\), over \(k = 1,\ldots, n\), i.e. $$B_n = \sum_{k=1}^{n}S(n, k),n \ge 1$$

Bell(n, exact = FALSE)

B(n, exact = FALSE)

Arguments

n

A vector of one or more non-zero positive integers

exact

if TRUE the exact results are returned as big integers of class bigz from the gmp package.

Value

A vector of Bell numbers. As with Stirling2, they are computed exactly and returned as doubles by default, or as exact bigz values if exact is TRUE.

See also

Stirling2

Author

James Curran

Examples


## returns B(6)
Bell(6)
#> [1] 203

## returns B(1), B(2), ..., B(6)
B(1:6)
#> [1]   1   2   5  15  52 203

## the exact value of B(50)
Bell(50, exact = TRUE)
#> Big Integer ('bigz') :
#> [1] 185724268771078270438257767181908917499221852770