Function stirlingS2 #

The Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. stirlingS2 only takes integer arguments. The following condition must be enforced: k <= n.

If n = k or k = 1 <= n, then s(n,k) = 1 If k = 0 < n, then s(n,k) = 0

Note that if either n or k is supplied as a bigint, the result will be as well. If not, and if either is a BigNumber, the result will be a BigNumber. Otherwise, the result will be a plain JavaScript number.

Syntax #

math.stirlingS2(n, k)

Parameters #

Parameter Type Description
n Number | BigNumber | bigint Total number of objects in the set
k Number | BigNumber | bigint Number of subsets

Returns #

Type Description
Number | BigNumber S2(n,k)

Throws #

Type | Description —- | ———–

Examples #

math.stirlingS2(5, 3) // returns 25
math.stirlingS2(math.bignumber(8), 3) // returns BigNumber 966
math.stirlingS2(18n, 3) // returns 64439010n

See also #

bellNumbers

History #

Version Comment
v15.3 added bigint support
v1.7 created
Fork me on GitHub