Skip to content

stirling1

specfun · scripts/specfun/stirling1.m

: s = stirling1 (n, k)

Unsigned Stirling numbers of the first kind.

stirling1 (N, K) returns the number of permutations of n elements with exactly k cycles (the unsigned cycle numbers c(n,k) = |s(n,k)|). Both n and k must be real non-negative integer scalars. The result is 0 when k > n (except c(0,0) = 1).

Output class follows nchoosek: double by default, single if either argument is single, or the common integer class when both arguments share one.

Behaviour note (MATLAB R2026a): stirling1 / stirling2 are not shipped by MathWorks in R2026a. This Nexus API uses the unsigned first-kind convention so stirling1 (5, 2) == 50 (nexus#1853 golden). Signed values are (-1)^(n-k) * stirling1 (n, k).