Stirling numbers of the first kind
func S1(n, k) { # unsigned Stirling numbers of the first kind
stirling(n, k).abs
}
const r = (0..12)
var triangle = r.map {|n| 0..n -> map {|k| S1(n, k) } }
var widths = r.map {|n| r.map {|k| (triangle[k][n] \\ 0).len }.max }
say ('n\k ', r.map {|n| "%*s" % (widths[n], n) }.join(' '))
r.each {|n|
var str = ('%-3s ' % n)
str += triangle[n].map_kv {|k,v| "%*s" % (widths[k], v) }.join(' ')
say str
}
with (100) {|n|
say "\nMaximum value from the S1(#{n}, *) row:"
say { S1(n, _) }.map(^n).max
}Output:
Alternatively, the S1(n,k) function can be defined as:
Last updated
Was this helpful?