Skip to content

binomial

binomial(n, k): bigint

Defined in: binomial.ts:16

The binomial coefficient C(n, k) — the number of k-element subsets of an n-element set.

Computed by the multiplicative recurrence C(n, k) = C(n, k−1) × (n − k + 1) / k, which stays within exact integer arithmetic at every step and never forms the intermediate factorials.

Uses the symmetry C(n, k) = C(n, n − k) so the loop runs min(k, n − k) times.

number

Size of the set, a non-negative integer.

number

Size of the subsets.

bigint

C(n, k), or 0 when k lies outside [0, n].