@@ -350,9 +350,45 @@ function lucasnum(n::Integer)
350350end
351351
352352"""
353- stirlings1(n::Integer, k::Integer)
353+ stirlings1(n::Integer, k::Integer, signed::Bool=false )
354354
355- Compute the Stirling number of the first kind, `s(n,k)`.
355+ Compute the Stirling number of the first kind, ``s(n,k)``.
356+
357+ If `signed` is `true`, return the signed value ``(-1)^{n-k} s(n,k)``.
358+
359+ # Examples
360+ ```jldoctest
361+ julia> stirlings1(5, 5) # s(n, n) = 1
362+ 1
363+
364+ julia> n=9; stirlings1(n, 1) == factorial(n-1)
365+ true
366+
367+ julia> n=233; stirlings1(n, n-1) == binomial(n,2)
368+ true
369+
370+ julia> stirlings1(6, 3, true)
371+ -225
372+
373+ julia> [(k<=n ? stirlings1(n,k,true) : 0) for n in 1:6, k in 1:6]
374+ 6×6 Matrix{Int64}:
375+ 1 0 0 0 0 0
376+ -1 1 0 0 0 0
377+ 2 -3 1 0 0 0
378+ -6 11 -6 1 0 0
379+ 24 -50 35 -10 1 0
380+ -120 274 -225 85 -15 1
381+
382+ julia> stirlings1(-1, 1)
383+ ERROR: DomainError with -1:
384+ n must be nonnegative
385+ Stacktrace:
386+ [...]
387+ ```
388+
389+ # References
390+ - [Stirling numbers of the first kind - Wikipedia](https://en.wikipedia.org/wiki/Stirling_numbers_of_the_first_kind)
391+ - [DLMF: §26.8 Stirling number of the first kind](https://dlmf.nist.gov/26.8#i.p1)
356392"""
357393function stirlings1 (n:: Integer , k:: Integer , signed:: Bool = false )
358394 if signed == true
0 commit comments